Common Lisp the Language 2nd Edition


next up previous contents index
Next: Integers Up: Data Types Previous: Data Types

2.1. Numbers

Several kinds of numbers are defined in Common Lisp. They are divided into integers; ratios; floating-point numbers with names provided for up to four different floating-point representations; and complex numbers.

change_begin
X3J13 voted in March 1989 (REAL-NUMBER-TYPE)   to add the type real.

The number data type encompasses all kinds of numbers. For convenience there are names for some subclasses of numbers as well. Integers and ratios are of type rational. Rational numbers and floating-point numbers are of type real. Real numbers and complex numbers are of type number.

Although the names of these types were chosen with the terminology of mathematics in mind the correspondences are not always exact. Integers and ratios model the corresponding mathematical concepts directly. Numbers of type float may be used to approximate real numbers both rational and irrational. The real type includes all Common Lisp numbers that represent mathematical real numbers though there are mathematical real numbers (irrational numbers) that do not have an exact Common Lisp representation. Only real numbers may be ordered using the < > <= <=/tt> numbers may be ordered using the <A> to add the type real..gif">