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.
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 will be nil
.
If the parameters have already been initialized, the function returns
immediately.
The algorithm makes assumptions that will be valid for almost all machines, but will fail if the machine’s arithmetic is extremely unusual, e.g., decimal.
Since true Common Lisp supports up to four different floating-point
precisions, it has families of constants like
most-positive-single-float
, most-positive-double-float
,
most-positive-long-float
, and so on. Emacs has only one
floating-point precision, so this package omits the precision word
from the constants’ names.
This constant equals the largest value a Lisp float can hold.
For those systems whose arithmetic supports infinities, this is
the largest finite value. For IEEE machines, the value
is approximately 1.79e+308
.
This constant equals the most negative value a Lisp float can hold.
(It is assumed to be equal to (- cl-most-positive-float)
.)
This constant equals the smallest Lisp float value greater than zero.
For IEEE machines, it is about 4.94e-324
if denormals are
supported or 2.22e-308
if not.
This constant equals the smallest normalized Lisp float greater
than zero, i.e., the smallest value for which IEEE denormalization
will not result in a loss of precision. For IEEE machines, this
value is about 2.22e-308
. For machines that do not support
the concept of denormalization and gradual underflow, this constant
will always equal cl-least-positive-float
.
This constant is the negative counterpart of cl-least-positive-float
.
This constant is the negative counterpart of
cl-least-positive-normalized-float
.
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 machines, epsilon
is about 2.22e-16
.
This is the smallest positive value that can be subtracted from
1.0 to produce a distinct value. For IEEE machines, it is about
1.11e-16
.
Previous: Random Numbers, Up: Numbers [Contents][Index]