[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
3.1 Exact numbers
Some numbers are represented as exact numbers: there is no loss of information
when such a number is converted from its mathematical value to its internal
representation. On exact numbers, the elementary operations (+
,
-
, *
, /
, comparisons, …) compute the completely
correct result.
In CLN, the exact numbers are:
- rational numbers (including integers),
- complex numbers whose real and imaginary parts are both rational numbers.
Rational numbers are always normalized to the form
numerator/denominator
where the numerator and denominator
are coprime integers and the denominator is positive. If the resulting
denominator is 1
, the rational number is converted to an integer.
Small integers (typically in the range -2^29
…2^29-1
,
for 32-bit machines) are especially efficient, because they consume no heap
allocation. Otherwise the distinction between these immediate integers
(called “fixnums”) and heap allocated integers (called “bignums”)
is completely transparent.
This document was generated on August 27, 2013 using texi2html 5.0.