Next: , Previous: , Up: Floats   [Contents][Index]


2.1.2.5 Floating Point Rounding Mode

IEEE floating point specifies four possible rounding modes:

:nearest

In this mode, the inexact results are rounded to the nearer of the two possible result values. If the neither possibility is nearer, then the even alternative is chosen. This form of rounding is also called “round to even”, and is the form of rounding specified for the Common Lisp round function.

:positive-infinity

This mode rounds inexact results to the possible value closer to positive infinity. This is analogous to the Common Lisp ceiling function.

:negative-infinity

This mode rounds inexact results to the possible value closer to negative infinity. This is analogous to the Common Lisp floor function.

:zero

This mode rounds inexact results to the possible value closer to zero. This is analogous to the Common Lisp truncate function.

Warning: Although the rounding mode can be changed with set-floating-point-modes, use of any value other than the default (:nearest) can cause unusual behavior, since it will affect rounding done by Common Lisp system code as well as rounding in user code. In particular, the unary round function will stop doing round-to-nearest on floats, and instead do the selected form of rounding.


Next: Accessing the Floating Point Modes, Previous: Floating Point Exceptions, Up: Floats   [Contents][Index]