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

6.2.2 Numerical predicates

Function: number? obj
Function: complex? obj
Function: real? obj
Function: rational? obj
Function: integer? obj
[R5RS] Returns #t if obj is a number, a complex number, a real number, a rational number or an integer, respectively. In Gauche, a set of numbers is the same as a set of complex numbers, and a set of rational numbers is the same as a set of integers.

 
(complex? 3+4i)   => #t
(complex? 3)      => #t
(real? 3)         => #t
(real? -2.5+0.0i) => #t
(real? #e1e10)    => #t
(integer? 3+0i)   => #t
(integer? 3.0)    => #t

Function: exact? obj
Function: inexact? obj
[R5RS] Returns #t if obj is an exact number and an inexact number, respectively.

 
(exact? 1)       => #t
(exact? 1.0)     => #f
(inexact? 1)     => #f
(inexact? 1.0)   => #t

(exact? (modulo 5 3)) => #t
(inexact? (modulo 5 3.0)) => #f

Function: zero? z
[R5RS] Returns #t if a number z equals to zero.

 
(zero? 1)        => #f
(zero? 0)        => #t
(zero? 0.0)      => #t
(zero? 0.0+0.0i) => #t

Function: positive? x
Function: negative? x
[R5RS] Returns #t if a real number x is positive and negative, respectively. It is an error to pass a non-real number.

Function: odd? n
Function: even? n
[R5RS] Returns #t if an integer n is odd and even, respectively. It is an error to pass a non-integral number.

 
(odd? 3)     => #t
(even? 3)    => #f
(odd? 3.0)   => #t

Function: fixnum? n
Function: bignum? n
Returns #t iff n is an exact integer whose internal representation is fixnum and bignum, respectively. Portable Scheme programs don't need to care about the internal representation of integer. These are for certain low-level routines that does particular optimization.


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

This document was generated by Ken Dickey on November, 28 2002 using texi2html