number?(3scm) Scheme Programmer's Manual number?(3scm)

number?, complex?, real?, rational?, integer? - numerical type predicates

(import (rnrs))                     ;R6RS
(import (rnrs base))                ;R6RS
(import (scheme r5rs))              ;R7RS
(import (scheme base))              ;R7RS

(number? obj)
(complex? obj)
(real? obj)
(rational? obj)
(integer? obj)

These numerical type predicates can be applied to any kind of argument, including non-numbers. They return #t if the object is of the named type, and #f otherwise.

In general, if a type predicate is true of a number then all higher type predicates are also true of that number. Consequently, if a type predicate is false of a number, then all lower type predicates are also false of that number.

If z is a complex number, then (real? z) is true if and only if (zero? (imag-part z)) is true. If x is an inexact real number, then (integer? x) is true if and only if (= x (round x)) is true.

The numbers +inf.0, -inf.0, and +nan.0 are real but not rational.

Returns a single boolean object.

(complex? 3+4i)    => #t
(complex? 3)       => #t
(real? 3)          => #t
(real? -2.5+0.0i)  => #f
(real? -2.5+0i)    => #t
(real? -2.5)       => #t
(real? #e1e10)     => #t
(rational? 6/10)   => #t
(rational? 6/3)    => #t
(rational? 2)      => #t
(integer? 3+0i)    => #t
(integer? 3.0)     => #t
(integer? 8/4)     => #t
(number? +nan.0)   => #t
(complex? +nan.0)  => #t
(real? +nan.0)     => #t
(rational? +nan.0) => #f
(complex? +inf.0)  => #t
(real? -inf.0)     => #t
(rational? -inf.0) => #f
(integer? -inf.0)  => #f

This procedure can raise exceptions with the following condition types:
&assertion (R6RS)
The wrong number of arguments was passed.
R7RS
The assertions described above are errors. Implementations may signal an error, extend the procedure's domain of definition to include such arguments, or fail catastrophically.

exact?(3scm), real-valued?(3scm)

R4RS, IEEE Scheme, R5RS, R6RS, R7RS

These procedures first appeared in R2RS.

This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at https://weinholt.se/scheme/manpages/.

2026-07-22