Next: baselib math ops comparison, Previous: baselib math ops exactness, Up: baselib math ops [Index]
These procedures return #t
if their arguments are (respectively):
equal, monotonically increasing, monotonically decreasing, monotonically
nondecreasing, or monotonically nonincreasing, and #f
otherwise.
Examples:
(= +inf.0 +inf.0) ⇒ #t (= -inf.0 +inf.0) ⇒ #f (= -inf.0 -inf.0) ⇒ #t
for any real number object x that is neither infinite nor NaN:
(< -inf.0 x +inf.0) ⇒ #t (> +inf.0 x -inf.0) ⇒ #t
for any number object z:
(= +nan.0 z) ⇒ #f
For any real number object x:
(< +nan.0 x) ⇒ #f (> +nan.0 x) ⇒ #f
These predicates must be transitive.
NOTE The traditional implementations of these predicates in Lisp–like languages are not transitive.
NOTE While it is possible to compare inexact number objects using these predicates, the results may be unreliable because a small inaccuracy may affect the result; this is especially true of
=
andzero?
(below).When in doubt, consult a numerical analyst.
These numerical predicates test a number object for a particular
property, returning #t
or #f
.
zero?
Tests if the number object is =
to zero.
positive?
Tests whether it is greater than zero.
negative?
Tests whether it is less than zero.
odd?
Tests whether it is odd.
even?
Tests whether it is even.
finite?
Tests whether it is not an infinity and not a NaN.
infinite?
Tests whether it is an infinity.
nan?
Tests whether it is a NaN.
(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 (finite? +inf.0) ⇒ #f (finite? 5) ⇒ #t (finite? 5.0) ⇒ #t (infinite? 5.0) ⇒ #f (infinite? +inf.0) ⇒ #t
NOTE As with the predicates above, the results may be unreliable because a small inaccuracy may affect the result.
Next: baselib math ops comparison, Previous: baselib math ops exactness, Up: baselib math ops [Index]