Common Lisp Extensions. Node: Implementation Parameters

PREV Random Numbers UP Numbers next

9.4: Implementation Parameters

This package defines several useful constants having to with numbers.

Variable: most-positive-fixnum
This constant equals the largest value a Lisp integer can hold. It is typically 2^23-1 or 2^25-1.
Variable: most-negative-fixnum
This constant equals the smallest (most negative) value a Lisp integer can hold.

The following parameters have to do with floating-point numbers. This package 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 most-positive-float have been initialized. Until it is called, these parameters will be nil. If this version of Emacs does not support floats (e.g., most versions of Emacs 18), the parameters will remain nil. If the parameters have already been initialized, the function returns immediately.

The algorithm makes assumptions that will be valid for most modern 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.

Variable: most-positive-float
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.
Variable: most-negative-float
This constant equals the most-negative value a Lisp float can hold. (It is assumed to be equal to (- most-positive-float).)
Variable: least-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.
Variable: least-positive-normalized-float
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 least-positive-float.
Variable: least-negative-float
This constant is the negative counterpart of least-positive-float.
Variable: least-negative-normalized-float
This constant is the negative counterpart of least-positive-normalized-float.
Variable: 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 machines, epsilon is about 2.22e-16.
Variable: float-negative-epsilon
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.
PREV Random Numbers UP Numbers next