Node:Numerical Tower, Next:, Up:Numbers

21.2.1 Scheme's Numerical "Tower"

Scheme's numerical "tower" consists of the following categories of numbers:

It is called a tower because each category "sits on" the one that follows it, in the sense that every integer is also a rational, every rational is also real, and every real number is also a complex number (but with zero imaginary part).

Of these, Guile implements integers, reals and complex numbers as distinct types. Rationals are implemented as regards the read syntax for rational numbers that is specified by R5RS, but are immediately converted by Guile to the corresponding real number.

The number? predicate may be applied to any Scheme value to discover whether the value is any of the supported numerical types.

number? obj Scheme Procedure
scm_number_p (obj) C Function
Return #t if obj is any kind of number, else #f.

For example:

(number? 3)

(number? "hello there!")

(define pi 3.141592654)
(number? pi)

The next few subsections document each of Guile's numerical data types in detail.