integer
integer System Class
Class Precedence List:
integer, rational, real, number, t
Description:
An integer is a mathematical integer. There is no limit on the magnitude of an integer . The types fixnum and bignum form an exhaustive partition of type integer.
Compound Type Specifier Kind:
Abbreviating.
Compound Type Specifier Syntax:
(integer [lower-limit [upper-limit]])
Compound Type Specifier Arguments:
lower-limit, upper-limit—interval designators for type integer. The defaults for each of lower-limit and upper-limit is the symbol *.
Compound Type Specifier Description:
This denotes the integers on the interval described by lower-limit and upper-limit.
See Also:
Figure 2–9, Section 2.3.2 (Constructing Numbers from Tokens), Section 22.1.3.1.1 (Printing Integers)
Notes:
The type (integer lower upper), where lower and upper are most-negative-fixnum and most-positive-fixnum, respectively, is also called fixnum.
The type (integer 0 1) is also called bit. The type (integer 0 *) is also called unsigned-byte.
Expanded Reference: integer
Type Checking
The integer type represents whole numbers with arbitrary precision. Every integer is either a fixnum or a bignum.
(typep 42 'integer)
=> T
(typep -7 'integer)
=> T
(typep 0 'integer)
=> T
(typep 3.14 'integer)
=> NIL
(typep 1/2 'integer)
=> NIL
(integerp 42)
=> T
Type Specifier with Range
The integer type specifier accepts optional lower and upper bounds, which is useful for declaring constrained integer types.
(typep 5 '(integer 0 10))
=> T
(typep 11 '(integer 0 10))
=> NIL
(typep -1 '(integer 0 *))
=> NIL
(typep 100 '(integer 0 *))
=> T
(typep 0 '(integer 0 0))
=> T
Type Hierarchy
The integer type is a subtype of rational, which is a subtype of real, which is a subtype of number.
(subtypep 'integer 'rational)
=> T
=> T
(subtypep 'integer 'real)
=> T
=> T
(subtypep 'integer 'number)
=> T
=> T
(subtypep 'fixnum 'integer)
=> T
=> T
(subtypep 'bignum 'integer)
=> T
=> T
Partitioning into fixnum and bignum
Every integer is exactly one of fixnum or bignum. The boundary is implementation-dependent.
(type-of 42)
;; => impl-dependent
(type-of (expt 2 100))
;; => impl-dependent
(typep most-positive-fixnum 'fixnum)
=> T
(typep (1+ most-positive-fixnum) 'bignum)
=> T