Next: , Up: scheme numbers   [Index]


3.3.1 Numerical tower

Numbers may be arranged into a tower of subsets in which each level is a subset of the level above it:

number
  complex
  real
  rational
  integer

For example, 5 is an integer. Therefore 5 is also a rational, a real, and a complex. The same is true of the number objects that model 5.

Number objects are organized as a corresponding tower of subtypes defined by the predicates number?, complex?, real?, rational?, and integer?. Numerical types predicates. Integer number objects are also called integer objects.

There is no simple relationship between the subset that contains a number and its representation inside a computer. For example, the integer 5 may have several representations. Scheme’s numerical operations treat number objects as abstract data, as independent of their representation as possible. Although an implementation of Scheme may use many different representations for numbers, this should not be apparent to a casual programmer writing simple programs.