summaryrefslogtreecommitdiff
path: root/pi.awk
diff options
context:
space:
mode:
authorwukong <wukong@longaeva>2018-11-12 22:35:51 -0800
committerwukong <wukong@longaeva>2018-11-12 22:35:51 -0800
commit7ab9ca8f57c44e812d3c782209a9e600dc513fbc (patch)
tree6be3ffecc7887d2d3a80d20ec907f955686e08df /pi.awk
parenta8064e8a631ed4ff1655575fe60423353fbc2b82 (diff)
added optional precision argv to other scripts;
Diffstat (limited to 'pi.awk')
-rw-r--r--pi.awk5
1 files changed, 2 insertions, 3 deletions
diff --git a/pi.awk b/pi.awk
index cb476ac..69eb36e 100644
--- a/pi.awk
+++ b/pi.awk
@@ -16,7 +16,6 @@ function pi() {
}
BEGIN {
- (ARGV[1] > 0) ? fig = ARGV[1] : fig = 6
- str = "%." fig "g\n"
- printf(str, pi())
+ ARGV[1] ? OFMT = "%." ARGV[1] "g" : OFMT = "%g"
+ printf(OFMT ORS, pi())
}