Common Lisp the Language, 2nd Edition


next up previous contents index
Next: Comparisons on Numbers Up: Numbers Previous: PrecisionContagion, and

12.2. Predicates on Numbers

Each of the following functions tests a single number for a specific property. Each function requires that its argument be a number; to call one with a non-number is an error.


[Function]
zerop number

This predicate is true if number is zero (the integer zero, a floating-point zero, or a complex zero), and is false otherwise. Regardless of whether an implementation provides distinct representations for positive and negative floating-point zeros, (zerop -0.0) is always true. It is an error if the argument number is not a number.


[Function]
plusp number

This predicate is true if number is strictly greater than zero, and is false otherwise. It is an error if the argument number is not a non-complex number.


[Function]
minusp number

This predicate is true if number is strictly less than zero, and is false otherwise. Regardless of whether an implementation provides distinct representations for positive and negative floating-point zeros, (minusp -0.0) is always false. (The function float-sign may be used to distinguish a negative zero.) It is an error if the argument number is not a non-complex number.


[Function]
oddp integer

This predicate is true if the argument integer is odd (not divisible by 2), and otherwise is false. It is an error if the argument is not an integer.


[Function]
evenp integer

This predicate is true if the argument integer is even (divisible by 2), and otherwise is false. It is an error if the argument is not an integer.

See also the data-type predicates integerp, rationalp, floatp, complexp, and numberp.



next up previous contents index
Next: Comparisons on Numbers Up: Numbers Previous: PrecisionContagion, and


AI.Repository@cs.cmu.edu