summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-02-24 20:15:17 -0800
committerKaz Kylheku <kaz@kylheku.com>2017-02-24 20:15:17 -0800
commitcf555eb22101b02bca5c0818ca4864a5b823acbc (patch)
tree6d7976666eaec919ffa7fbc51ee89190726eda8b /txr.1
parent77491d210b391d82cbf1a9b623092fb3caadba90 (diff)
downloadtxr-cf555eb22101b02bca5c0818ca4864a5b823acbc.tar.gz
txr-cf555eb22101b02bca5c0818ca4864a5b823acbc.tar.bz2
txr-cf555eb22101b02bca5c0818ca4864a5b823acbc.zip
floor and ceil do division, with optional second arg.
Also, with one argument, these functions handle ranges. * arith.c (floordiv, ceildiv): New functions. (floorf, ceili): Handle ranges. * eval.c (eval_init): Register floor and ceil to new functions. * lib.h (floordiv, ceildiv): Declared. * txr.1: Documentation updated.
Diffstat (limited to 'txr.1')
-rw-r--r--txr.161
1 files changed, 47 insertions, 14 deletions
diff --git a/txr.1 b/txr.1
index 6daca213..43cf2bf4 100644
--- a/txr.1
+++ b/txr.1
@@ -31690,27 +31690,60 @@ returned: a positive number of the same type with exactly the same magnitude.
.coNP Functions @ floor and @ ceil
.synb
-.mets (floor << number )
-.mets (ceil << number )
+.mets (floor < dividend <> [ divisor ])
+.mets (ceil < dividend <> [ divisor ])
.syne
.desc
The
.code floor
+and
+.code ceiling
+functions perform division of the
+.meta dividend
+by the
+.metn divisor ,
+returning an integer quotient.
+
+If the
+.meta divisor
+is omitted, it defaults to 1.
+
+If both inputs are integers,
+the result is of type integer.
+
+If all inputs are numbers and at least one of them is
+floating-point, the others are converted to floating-point
+and the result is floating-point.
+
+The
+.code dividend
+input may be a range. In this situation, the operation is
+recursively distributed over the
+.code from
+and
+.code to
+fields of the range, individually matched against the
+.metn divisor ,
+and the result is a range composed of these two individual
+quotients.
+
+When the quotient is a scalar value,
+.code floor
function returns the highest integer which does not exceed
-the value of
-.metn number .
-The ceiling function returns the lowest integer which
+the value of the quotient. That is to say, the division is
+truncated to an integer value toward negative infinity.
+The
+.code ceil
+function the lowest integer which is not below the value
+of the quotient.
does not exceed the value of
-.metn number .
-
-If
-.meta number
-an integer, it is simply returned.
+.metn dividend .
+That is to say, the division is truncated to an integer
+value toward positive infinity.
-If the argument is a float, then the value returned is a float.
-For instance
-.code "(floor 1.1)"
-returns 1.0 rather than 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.
.coNP Functions @, sin @, cos @, tan @, asin @, acos @ atan and @ atan2
.synb