www.delorie.com/gnu/docs/guile/guile_170.html   search  
 
Buy GNU books!


Guile Reference Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

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.

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

For example:

 
(number? 3)
=>
#t

(number? "hello there!")
=>
#f

(define pi 3.141592654)
(number? pi)
=>
#t

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


  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003