real-valued?(3scm) Scheme Programmer's Manual real-valued?(3scm)

real-valued?, rational-valued?, integer-valued? - numerical type predicates that ignore an inexact zero imaginary part

(import (rnrs))                     ;R6RS
(import (rnrs base))                ;R6RS

(real-valued? obj)
(rational-valued? obj)
(integer-valued? obj)

These numerical type predicates can be applied to any kind of argument. The real-valued? procedure returns #t if the object is a number object and is equal in the sense of = to some real number object, or if the object is a NaN, or a complex number object whose real part is a NaN and whose imaginary part is zero in the sense of zero?. The rational-valued? and integer-valued? procedures return #t if the object is a number object and is equal in the sense of = to some object of the named type, and otherwise they return #f.

These procedures test whether a given number object can be coerced to the specified type without loss of numerical accuracy. Specifically, the behavior of these predicates differs from the behavior of real?, rational?, and integer? on complex number objects whose imaginary part is inexact zero.

The behavior of these type predicates on inexact number objects is unreliable, because any inaccuracy may affect the result.

Returns a single boolean object.

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

These procedures are unique to R6RS. R7RS provides only real?, rational?, and integer? (see number?(3scm)), which differ on complex number objects whose imaginary part is inexact zero.

This procedure can raise exceptions with the following condition types:
&assertion (R6RS)
The wrong number of arguments was passed.

number?(3scm), exact?(3scm)

R6RS

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