Next: Category comparable, Previous: Category rational, Up: Unions of Number Types [Contents][Index]
The category of reals consists of the emacs floats and all arbitrary real-approximations (‘bigf’, ‘bigfr’ if provided). Possibly, if provided, it contains the symbolic “number” objects for positive and negative infinity, as well as not-a-number.
Important note: As stated in the definition above, rationals are not in the category of reals. This might seem contradictory, because (especially in school mathematics or calculus classes) reals are sometimes defined as the union of rationals and irrationals. From the algebraic view, this is approach is inconsistent. Please see Category comparable. On the other hand, the non-ENT equivalent of real would be float, and in terms of non-ENT emacsen, fixnums are no floats.
The category’s predicate is realp
.
Return t
if object is real (i.e. a float or one of the
arbitrary-precision floats), nil
otherwise.
(realp 0.0) ⇒ t (realp (exp 1)) ⇒ t (realp (coerce 1 'bigf)) ⇒ t (realp +infinity) ⇒ t (realp not-a-number) ⇒ t
(realp 1) ⇒ nil (realp 1/2) ⇒ nil
Additionally, the category real has some variables to control which float implementation is used. This is necessary as there is no information about loss of precision, and there is no function to measure if a float number would fit in one type or the other.
Indicate how real numbers should be read. If set to ‘nil’ or ’float, reals are always converted to floats. If set to ’bigf or ’bigfr, reals are read as MPF floats or MPFR floats respectively.
The default floating-point precision for newly created floating point values. This should be an unsigned integer no greater than max-real-precision to create external floats with the indicated precision.
This variable is effective only when read-real-as is set to a float type which supports setting a precision.
The maximum number of bits of precision a ‘bigf’ or ‘bigfr’ can have. This is determined by the underlying library used to implement arbitrary-precision floats.
Next: Category comparable, Previous: Category rational, Up: Unions of Number Types [Contents][Index]