diff options
| -rw-r--r-- | lispref/numbers.texi | 32 |
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, |
| 172 | provides for positive infinity and negative infinity as floating point | 172 | which provides for positive infinity and negative infinity as floating point |
| 173 | values. It also provides for a class of values called NaN or | 173 | values. 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 |
| 175 | there is no correct answer. For example, @code{(sqrt -1.0)} returns a | 175 | there 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 |
| 192 | zero in @acronym{IEEE} floating point (although @code{equal} and @code{=} consider | 192 | zero in @acronym{IEEE} floating point (although @code{equal} and |
| 193 | them 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 |
| 196 | point number (or estimate the logarithm of an integer): | 196 | point number (or estimate the logarithm of an integer): |
| @@ -379,10 +379,16 @@ it unchanged. | |||
| 379 | @end defun | 379 | @end defun |
| 380 | 380 | ||
| 381 | There are four functions to convert floating point numbers to integers; | 381 | There are four functions to convert floating point numbers to integers; |
| 382 | they differ in how they round. These functions accept integer arguments | 382 | they differ in how they round. All accept an argument @var{number} |
| 383 | also, and return such arguments unchanged. | 383 | and an optional argument @var{divisor}. Both arguments may be |
| 384 | 384 | integers 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 |
| 386 | functions convert @var{number} to an integer, or return it unchanged | ||
| 387 | if it already is an integer. If @var{divisor} is non-@code{nil}, they | ||
| 388 | divide @var{number} by @var{divisor} and convert the result to an | ||
| 389 | integer. An @code{arith-error} results if @var{divisor} is 0. | ||
| 390 | |||
| 391 | @defun truncate number &optional divisor | ||
| 386 | This returns @var{number}, converted to an integer by rounding towards | 392 | This returns @var{number}, converted to an integer by rounding towards |
| 387 | zero. | 393 | zero. |
| 388 | 394 | ||
| @@ -402,10 +408,8 @@ zero. | |||
| 402 | This returns @var{number}, converted to an integer by rounding downward | 408 | This returns @var{number}, converted to an integer by rounding downward |
| 403 | (towards negative infinity). | 409 | (towards negative infinity). |
| 404 | 410 | ||
| 405 | If @var{divisor} is specified, @code{floor} divides @var{number} by | 411 | If @var{divisor} is specified, this uses the kind of division |
| 406 | @var{divisor} and then converts to an integer; this uses the kind of | 412 | operation that corresponds to @code{mod}, rounding downward. |
| 407 | division operation that corresponds to @code{mod}, rounding downward. | ||
| 408 | An @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 |
| 425 | This returns @var{number}, converted to an integer by rounding upward | 429 | This 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 |
| 441 | This returns @var{number}, converted to an integer by rounding towards the | 445 | This returns @var{number}, converted to an integer by rounding towards the |
| 442 | nearest integer. Rounding a value equidistant between two integers | 446 | nearest integer. Rounding a value equidistant between two integers |
| 443 | may choose the integer closer to zero, or it may prefer an even integer, | 447 | may choose the integer closer to zero, or it may prefer an even integer, |