1
0
Fork 0
cl-sites/www.cs.cmu.edu/Groups/AI/html/cltl/clm/node123.html
2023-10-25 11:23:21 +02:00

69 lines
3.9 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN">
<!Converted with LaTeX2HTML 0.6.5 (Tue Nov 15 1994) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds >
<HEAD>
<TITLE>12.2. Predicates on Numbers</TITLE>
</HEAD>
<BODY>
<meta name="description" value=" Predicates on Numbers">
<meta name="keywords" value="clm">
<meta name="resource-type" value="document">
<meta name="distribution" value="global">
<P>
<b>Common Lisp the Language, 2nd Edition</b>
<BR> <HR><A NAME=tex2html3066 HREF="node124.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html3064 HREF="node121.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html3058 HREF="node122.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html3068 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html3069 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME=tex2html3067 HREF="node124.html"> Comparisons on Numbers</A>
<B>Up:</B> <A NAME=tex2html3065 HREF="node121.html"> Numbers</A>
<B> Previous:</B> <A NAME=tex2html3059 HREF="node122.html"> PrecisionContagion, and </A>
<HR> <P>
<H1><A NAME=SECTION001620000000000000000>12.2. Predicates on Numbers</A></H1>
<P>
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.
<P>
<BR><b>[Function]</b><BR>
<tt>zerop <i>number</i></tt><P>This predicate is true if <i>number</i> 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,
<tt>(zerop -0.0)</tt> is always true.
It is an error if the argument <i>number</i> is not a number.
<P>
<BR><b>[Function]</b><BR>
<tt>plusp <i>number</i></tt><P>This predicate is true if <i>number</i> is strictly greater than zero,
and is false otherwise.
It is an error if the argument <i>number</i> is not a non-complex number.
<P>
<BR><b>[Function]</b><BR>
<tt>minusp <i>number</i></tt><P>This predicate is true if <i>number</i> is strictly less than zero,
and is false otherwise.
Regardless of whether an implementation provides distinct representations
for positive and negative floating-point zeros,
<tt>(minusp -0.0)</tt> is always false.
(The function <tt>float-sign</tt> may be used to distinguish a negative zero.)
It is an error if the argument <i>number</i> is not a non-complex number.
<P>
<BR><b>[Function]</b><BR>
<tt>oddp <i>integer</i></tt><P>This predicate is true if the argument <i>integer</i> is odd (not divisible
by 2), and otherwise is false. It is an error if the argument is not
an integer.
<P>
<BR><b>[Function]</b><BR>
<tt>evenp <i>integer</i></tt><P>This predicate is true if the argument <i>integer</i> is even (divisible
by 2), and otherwise is false. It is an error if the argument is not
an integer.
<P>
See also the data-type predicates <tt>integerp</tt>,
<tt>rationalp</tt>, <tt>floatp</tt>, <tt>complexp</tt>, and <tt>numberp</tt>.
<P>
<BR> <HR><A NAME=tex2html3066 HREF="node124.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html3064 HREF="node121.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html3058 HREF="node122.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html3068 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html3069 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME=tex2html3067 HREF="node124.html"> Comparisons on Numbers</A>
<B>Up:</B> <A NAME=tex2html3065 HREF="node121.html"> Numbers</A>
<B> Previous:</B> <A NAME=tex2html3059 HREF="node122.html"> PrecisionContagion, and </A>
<HR> <P>
<HR>
<P><ADDRESS>
AI.Repository@cs.cmu.edu
</ADDRESS>
</BODY>