diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-02-25 05:09:34 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-02-25 05:09:34 -0800 |
commit | 1aff5cbf9c7c79c1deb58d6b985f2bd03c51a4ba (patch) | |
tree | 9d542f46972db880d33217b508d0e24d34c1c8f4 /txr.1 | |
parent | cf555eb22101b02bca5c0818ca4864a5b823acbc (diff) | |
download | txr-1aff5cbf9c7c79c1deb58d6b985f2bd03c51a4ba.tar.gz txr-1aff5cbf9c7c79c1deb58d6b985f2bd03c51a4ba.tar.bz2 txr-1aff5cbf9c7c79c1deb58d6b985f2bd03c51a4ba.zip |
Adding round function.
* arith.c (round1): New static function.
(roundiv): New function.
* configure: New test for C99 round function.
* eval.c (eval_init): Register round intrinsic.
* txr.1: Documented.
Diffstat (limited to 'txr.1')
-rw-r--r-- | txr.1 | 29 |
1 files changed, 25 insertions, 4 deletions
@@ -31688,16 +31688,18 @@ is positive, it is returned. If is negative, its additive inverse is returned: a positive number of the same type with exactly the same magnitude. -.coNP Functions @ floor and @ ceil +.coNP Functions @, floor @ ceil and @ round .synb .mets (floor < dividend <> [ divisor ]) .mets (ceil < dividend <> [ divisor ]) +.mets (round < dividend <> [ divisor ]) .syne .desc The -.code floor -and +.codn floor , .code ceiling +and +.code round functions perform division of the .meta dividend by the @@ -31739,12 +31741,31 @@ of the quotient. does not exceed the value of .metn dividend . That is to say, the division is truncated to an integer -value toward positive infinity. +value toward positive infinity. The +.code round +function returns the nearest integer to the quotient. +Exact halfway cases are rounded to the integer away from +zero so that +.code "(round -1 2)" +yields +.code -1 +and +.code "(round 1 2)" +yields 1, Note that for large floating point values, due to the limited precision, the integer value corresponding to the mathematical floor or ceiling may not be available. +.TP* "Dialect note:" +In ANSI Common Lisp, the +.code round +function chooses the nearest even integer, rather than +rounding halfway cases away from zero. \*(TX's choice +harmonizes with the semantics of the +.code round +function in the C language. + .coNP Functions @, sin @, cos @, tan @, asin @, acos @ atan and @ atan2 .synb .mets (sin << radians ) |