2.3. Integers

Common-Lisp distinguishes two types of integer types: bignums and fixnums. A fixnum is a small integer, which ideally occupies only a word of memory and which is between the values MOST-NEGATIVE-FIXNUM and MOST-POSITIVE-FIXNUM. A bignum is any integer which is not a fixnum and it is only constrained by the amount of memory available to represent it.

In ECL a fixnum is an integer that, together with the tag bits, fits in a word of memory. The size of a word, and thus the size of a fixnum, varies from one architecture to another, and you should refer to the types and constants in the ecl.h header to make sure that your C extensions are portable. All other integers are stored as bignums, they are not immediate objects, they take up a variable amount of memory and the GNU Multiprecision Library is required to create, manipulate and calculate with them.

 C type: cl_fixnum

This is a C signed integer type capable of holding a whole fixnum without any loss of precision. The opposite is not true, and you may create a cl_fixnum which exceeds the limits of a fixnum and should be stored as a bignum.

 C type: cl_index

This is a C unsigned integer type capable of holding a nonnegative fixnum without loss of precision. Typically, a cl_index is used as an index into an array, or into a proper list, etc.


These constants mark the limits of a fixnum.

 Function: bool FIXNUM_MINUSP (cl_object o)
 Function: bool FIXNUM_PLUSP (cl_object o)

These functions perform the checks (o < 0) and (0 <= o), respectively.

 Function: cl_object MAKE_FIXNUM (cl_fixnum n)
 Function: cl_fixnum fix (cl_object o)

MAKE_FIXNUM and fix convert from an integer to a lisp object of fixnum type and vice versa. These functions no not check their arguments.

 Function: cl_fixnum fixint (cl_object o)

Converts a lisp fixnum to a C integer of the appropriate size. Signals an error if o is not of fixnum type.

 Function: cl_index fixnnint (cl_object o)

Similar to fixint but also ensures that o is not negative.