Previous: Random Numbers, Up: Numbers [Contents][Index]

This package defines several useful constants having to do with floating-point numbers.

It determines their values by exercising the computer’s floating-point arithmetic in various ways. Because this operation might be slow, the code for initializing them is kept in a separate function that must be called before the parameters can be used.

- Function:
**cl-float-limits**¶ This function makes sure that the Common Lisp floating-point parameters like

`cl-most-positive-float`

have been initialized. Until it is called, these parameters have unspecified values. If the parameters have already been initialized, the function returns immediately.

Since true Common Lisp supports up to four different kinds of floating-point
numbers, it has families of constants like
`most-positive-single-float`

, `most-positive-double-float`

,
`most-positive-long-float`

, and so on. This package uses just
one set of constants because Emacs has only one kind of
floating-point number, namely the IEEE binary64 floating-point format.
See Float Basics in GNU Emacs Lisp Reference Manual.

- Variable:
**cl-most-positive-float**¶ This constant equals the largest finite value a Lisp float can hold. For IEEE binary64 format, this equals

`(- (expt 2 1024) (expt 2 971))`

, which equals`1.7976931348623157e+308`

.

- Variable:
**cl-most-negative-float**¶ This constant equals the most negative finite value a Lisp float can hold. For IEEE binary64 format, this equals

`(- cl-most-positive-float)`

.

- Variable:
**cl-least-positive-normalized-float**¶ This constant equals the smallest positive Lisp float that is

*normalized*, i.e., that has full precision. For IEEE binary64 format, this equals`(expt 2 -1022)`

, which equals`2.2250738585072014e-308`

.

- Variable:
**cl-least-positive-float**¶ This constant equals the smallest Lisp float value greater than zero. For IEEE binary64 format, this equals

`5e-324`

(which equals`(expt 2 -1074)`

) if subnormal numbers are supported, and`cl-least-positive-normalized-float`

otherwise.

- Variable:
**cl-least-negative-float**¶ This constant is the negative counterpart of

`cl-least-positive-float`

.

- Variable:
**cl-least-negative-normalized-float**¶ This constant is the negative counterpart of

`cl-least-positive-normalized-float`

.

- Variable:
**cl-float-epsilon**¶ This constant is the smallest positive Lisp float that can be added to 1.0 to produce a distinct value. Adding a smaller number to 1.0 will yield 1.0 again due to roundoff. For IEEE binary64 format, this equals

`(expt 2 -52)`

, which equals`2.220446049250313e-16`

.

- Variable:
**cl-float-negative-epsilon**¶ This is the smallest positive value that can be subtracted from 1.0 to produce a distinct value. For IEEE binary64 format, this equals

`(expt 2 -53)`

, which equals`1.1102230246251565e-16`

.

Previous: Random Numbers, Up: Numbers [Contents][Index]