negative?, positive?, odd?, even?, flnegative?, flpositive?, flodd?, fleven?, fxnegative?, fxpositive?, fxodd?, fxeven?- numerical predicates
(import (rnrs)) ;R6RS
(import (rnrs base)) ;R6RS
(import (scheme r5rs)) ;R7RS
(import (scheme base)) ;R7RS
(import (rnrs arithmetic flonums)) ;R6RS
(import (rnrs arithmetic fixnums)) ;R6RS
These numerical predicates test a number object for a particular
- Properties tested
The predicates tests the following properties.
[1mzero? [22mtests if the number is = to zero
[1mpositive? [22mtests if the number is greater than zero
[1mnegative? [22mtests if the number is less than zero
[1modd? [22mtests if the number is odd
[1meven? [22mtests if the number is even
- Flonum variants
These variants restrict their arguments to flonums.
- Fixnum variants
These variants restrict their arguments to fixnums.
Unless the number is exact, the results may be unreliable because a
small inaccuracy may affect the result.
Returns a single value; a boolean.
(zero? +0.0) => #t
(zero? -0.0) => #t
(zero? +nan.0) => #f
(positive? +inf.0) => #t
(negative? -inf.0) => #t
(positive? +nan.0) => #f
(negative? +nan.0) => #f
These procedures work the same in all Scheme revisions since R2RS.
This procedure can raise exceptions with the following condition types:
- &assertion (R6RS)
The wrong number of arguments was passed or an argument was outside its domain.
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.
These procedures were first introduced in R2RS. Scheme before then,
running on MacLisp, had access to similar predicates:
LISP 1.5 had a
predicate that returned true for negative numbers, including -0.
It also had
predicates. These were specified to true when the absolute difference
between the argument and zero or one, respectively, is less than 3e-6.
This page is part of the
It includes materials from the RnRS documents.
More information can be found at
Markup created by unroff 1.0sc, March 04, 2023.