diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2014-08-12 21:15:26 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2014-08-12 21:15:26 +0300 |
commit | 9e2907afe246b3930d9ae6043a2657c4492f4507 (patch) | |
tree | 799ffdc8dfda7ac5af9083573b23f434ad964d8f | |
parent | e43ac01de95f05ac3c56f20d35329d086052ced2 (diff) | |
download | egawk-9e2907afe246b3930d9ae6043a2657c4492f4507.tar.gz egawk-9e2907afe246b3930d9ae6043a2657c4492f4507.tar.bz2 egawk-9e2907afe246b3930d9ae6043a2657c4492f4507.zip |
Add div.awk to awklib.
-rw-r--r-- | awklib/eg/lib/div.awk | 17 | ||||
-rw-r--r-- | doc/ChangeLog | 4 | ||||
-rw-r--r-- | doc/gawk.texi | 13 | ||||
-rw-r--r-- | doc/gawktexi.in | 13 |
4 files changed, 47 insertions, 0 deletions
diff --git a/awklib/eg/lib/div.awk b/awklib/eg/lib/div.awk new file mode 100644 index 00000000..9d919288 --- /dev/null +++ b/awklib/eg/lib/div.awk @@ -0,0 +1,17 @@ +# div --- do integer division + +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# July, 2014 + +function div(numerator, denominator, result, i) +{ + split("", result) + + numerator = int(numerator) + denominator = int(denominator) + result["quotient"] = int(numerator / denominator) + result["remainder"] = int(numerator % denominator) + + return 0.0 +} diff --git a/doc/ChangeLog b/doc/ChangeLog index 0500b6c9..82997ac8 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,7 @@ +2014-08-12 Arnold D. Robbins <arnold@skeeve.com> + + * gawktexi.in: Cause div.awk to get into the example files. + 2014-08-06 Arnold D. Robbins <arnold@skeeve.com> * gawktexi.in: Misc minor additions. diff --git a/doc/gawk.texi b/doc/gawk.texi index f2b455b4..6bbc6562 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -30565,8 +30565,20 @@ You can simulate the @code{div()} function in standard @command{awk} using this user-defined function: @example +@c file eg/lib/div.awk # div --- do integer division +@c endfile +@ignore +@c file eg/lib/div.awk +# +# Arnold Robbins, arnold@@skeeve.com, Public Domain +# July, 2014 + +@c endfile + +@end ignore +@c file eg/lib/div.awk function div(numerator, denominator, result, i) @{ split("", result) @@ -30578,6 +30590,7 @@ function div(numerator, denominator, result, i) return 0.0 @} +@c endfile @end example @node POSIX Floating Point Problems diff --git a/doc/gawktexi.in b/doc/gawktexi.in index bb94aa1f..bca15569 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -29680,8 +29680,20 @@ You can simulate the @code{div()} function in standard @command{awk} using this user-defined function: @example +@c file eg/lib/div.awk # div --- do integer division +@c endfile +@ignore +@c file eg/lib/div.awk +# +# Arnold Robbins, arnold@@skeeve.com, Public Domain +# July, 2014 + +@c endfile + +@end ignore +@c file eg/lib/div.awk function div(numerator, denominator, result, i) @{ split("", result) @@ -29693,6 +29705,7 @@ function div(numerator, denominator, result, i) return 0.0 @} +@c endfile @end example @node POSIX Floating Point Problems |