Chapter 12. Numbers

12.1. Numeric types
12.2. Random-States
12.3. C Reference
Number C types — Numeric C types understood by ECL
Number constructors — Creating Lisp types from C numbers
Number accessors — Unchecked conversion from Lisp types to C numbers
Number coercion — Checked conversion from Lisp types to C numbers
Numbers C dictionary — Common Lisp and C equivalence

12.1. Numeric types

ECL supports all of the Common Lisp numeric tower, which is shown in Table 12.1. The details, however, depend both on the platform on which ECL runs and on the configuration which was chosen when building ECL.

Table 12.1. Numeric types in ECL

fixnumSigned integer with a number of bits given by ext:fixnum-bits, fit in a machine word.
bignumArbitrary size integers, only limited by amount of memory.
ratioArbitrary size rational number, made up of two integers.
short-floatEquivalent to single-float.
single-float32-bits IEEE floating point number.
double-float64-bits IEEE floating point number.
long-floatEither equivalent to double-float, or a 96/128 bits IEEE floating point number (long double in C/C++).
rationalAn alias for (or integer ratio)
floatAn alias for (or single-float double-float short-float long-float)
realAn alias for (or real integer float)
complexComplex number made of two real numbers of the above mentioned types.

In general, the size of a FIXNUM is determined by the word size of a machine, which ranges from 32 to 64 bits. Integers larger than this are implemented using the GNU Multiprecision library. Rationals are implemented using two integers, without caring whether they are fixnum or not. Floating point numbers include at least the two IEEE types of 32 and 64 bits respectively. In machines where it is supported, it is possible to associate the lisp LONG-FLOAT with the machine type long double whose size ranges from 96 to 128 bits, and which are a bit slower.