aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuc Teirlinck2003-11-12 21:30:14 +0000
committerLuc Teirlinck2003-11-12 21:30:14 +0000
commitfa091c040c83ac95bece4adf541acaa41850716f (patch)
treed7e8dd0362f4aa12b84ae1203cf2f22a58abdf55
parentc5e2fb05c10352b5e013fff956f1468b233dbda7 (diff)
downloademacs-fa091c040c83ac95bece4adf541acaa41850716f.tar.gz
emacs-fa091c040c83ac95bece4adf541acaa41850716f.zip
(Numeric Conversions): Not just `floor', but also `truncate',
`ceiling' and `round' accept optional argument DIVISOR.
-rw-r--r--lispref/numbers.texi32
1 files changed, 18 insertions, 14 deletions
diff --git a/lispref/numbers.texi b/lispref/numbers.texi
index fbbac56963e..63f3035dfcf 100644
--- a/lispref/numbers.texi
+++ b/lispref/numbers.texi
@@ -168,8 +168,8 @@ to write negative floating point numbers, as in @samp{-1.0}.
168@cindex negative infinity 168@cindex negative infinity
169@cindex infinity 169@cindex infinity
170@cindex NaN 170@cindex NaN
171 Most modern computers support the @acronym{IEEE} floating point standard, which 171 Most modern computers support the @acronym{IEEE} floating point standard,
172provides for positive infinity and negative infinity as floating point 172which provides for positive infinity and negative infinity as floating point
173values. It also provides for a class of values called NaN or 173values. It also provides for a class of values called NaN or
174``not-a-number''; numerical functions return such values in cases where 174``not-a-number''; numerical functions return such values in cases where
175there is no correct answer. For example, @code{(sqrt -1.0)} returns a 175there is no correct answer. For example, @code{(sqrt -1.0)} returns a
@@ -189,8 +189,8 @@ these special floating point values:
189@end table 189@end table
190 190
191 In addition, the value @code{-0.0} is distinguishable from ordinary 191 In addition, the value @code{-0.0} is distinguishable from ordinary
192zero in @acronym{IEEE} floating point (although @code{equal} and @code{=} consider 192zero in @acronym{IEEE} floating point (although @code{equal} and
193them equal values). 193@code{=} consider them equal values).
194 194
195 You can use @code{logb} to extract the binary exponent of a floating 195 You can use @code{logb} to extract the binary exponent of a floating
196point number (or estimate the logarithm of an integer): 196point number (or estimate the logarithm of an integer):
@@ -379,10 +379,16 @@ it unchanged.
379@end defun 379@end defun
380 380
381There are four functions to convert floating point numbers to integers; 381There are four functions to convert floating point numbers to integers;
382they differ in how they round. These functions accept integer arguments 382they differ in how they round. All accept an argument @var{number}
383also, and return such arguments unchanged. 383and an optional argument @var{divisor}. Both arguments may be
384 384integers or floating point numbers. @var{divisor} may also be
385@defun truncate number 385@code{nil}. If @var{divisor} is @code{nil} or omitted, these
386functions convert @var{number} to an integer, or return it unchanged
387if it already is an integer. If @var{divisor} is non-@code{nil}, they
388divide @var{number} by @var{divisor} and convert the result to an
389integer. An @code{arith-error} results if @var{divisor} is 0.
390
391@defun truncate number &optional divisor
386This returns @var{number}, converted to an integer by rounding towards 392This returns @var{number}, converted to an integer by rounding towards
387zero. 393zero.
388 394
@@ -402,10 +408,8 @@ zero.
402This returns @var{number}, converted to an integer by rounding downward 408This returns @var{number}, converted to an integer by rounding downward
403(towards negative infinity). 409(towards negative infinity).
404 410
405If @var{divisor} is specified, @code{floor} divides @var{number} by 411If @var{divisor} is specified, this uses the kind of division
406@var{divisor} and then converts to an integer; this uses the kind of 412operation that corresponds to @code{mod}, rounding downward.
407division operation that corresponds to @code{mod}, rounding downward.
408An @code{arith-error} results if @var{divisor} is 0.
409 413
410@example 414@example
411(floor 1.2) 415(floor 1.2)
@@ -421,7 +425,7 @@ An @code{arith-error} results if @var{divisor} is 0.
421@end example 425@end example
422@end defun 426@end defun
423 427
424@defun ceiling number 428@defun ceiling number &optional divisor
425This returns @var{number}, converted to an integer by rounding upward 429This returns @var{number}, converted to an integer by rounding upward
426(towards positive infinity). 430(towards positive infinity).
427 431
@@ -437,7 +441,7 @@ This returns @var{number}, converted to an integer by rounding upward
437@end example 441@end example
438@end defun 442@end defun
439 443
440@defun round number 444@defun round number &optional divisor
441This returns @var{number}, converted to an integer by rounding towards the 445This returns @var{number}, converted to an integer by rounding towards the
442nearest integer. Rounding a value equidistant between two integers 446nearest integer. Rounding a value equidistant between two integers
443may choose the integer closer to zero, or it may prefer an even integer, 447may choose the integer closer to zero, or it may prefer an even integer,