X-Git-Url: https://git.xandkar.net/?p=khatus.git;a=blobdiff_plain;f=src%2Fawk%2Flib%2Fnum.awk;fp=src%2Fawk%2Flib%2Futil.awk;h=4c22f9d676b7f172d8e9ba785fc3170b6a761018;hp=b7a92e6e7fb972590f9c18cca0b162166d15b15d;hb=8482fea64a51f9a9b97895c974a88a986b42aa15;hpb=e103315c72597a9cc9fffaaff11e04b30d1c6416 diff --git a/src/awk/lib/util.awk b/src/awk/lib/num.awk similarity index 84% rename from src/awk/lib/util.awk rename to src/awk/lib/num.awk index b7a92e6..4c22f9d 100755 --- a/src/awk/lib/util.awk +++ b/src/awk/lib/num.awk @@ -1,20 +1,14 @@ -function util_strip(s) { - sub("^ *", "", s) - sub(" *$", "", s) - return s -} - -function util_round(n) { +function num_round(n) { return int(n + 0.5) } -function util_ensure_numeric(n) { +function num_ensure_numeric(n) { return n + 0 } -#------------------------------------ -# Why do we need util_ensure_numeric? -#------------------------------------ +#----------------------------------- +# Why do we need num_ensure_numeric? +#----------------------------------- # awk appears to be guessing the type of an inputted scalar based on usage, so # if we read-in a number, but did not use it in any numeric operations, but did # use as a string (even in just a format string!) - it will be treated as a