Numeric Comparisons

The function **=** is the numeric equality predicate. It compares numbers by mathematical value, ignoring differences in type. Thus, **=** will consider mathematically equivalent values of different types equivalent while the generic equality predicate **EQL** would consider them inequivalent because of the difference in type. (The generic equality predicate **EQUALP**, however, uses **=** to compare numbers.) If it’s called with more than two arguments, it returns true only if they all have the same value. Thus:

  1. (= 1 1) ==> T
  2. (= 10 20/2) ==> T
  3. (= 1 1.0 #c(1.0 0.0) #c(1 0)) ==> T

The **/=** function, conversely, returns true only if all its arguments are different values.

  1. (/= 1 1) ==> NIL
  2. (/= 1 2) ==> T
  3. (/= 1 2 3) ==> T
  4. (/= 1 2 3 1) ==> NIL
  5. (/= 1 2 3 1.0) ==> NIL

The functions **<**, **>**, **<=**, and **>=** order rationals and floating-point numbers (in other words, the real numbers.) Like **=** and **/=**, these functions can be called with more than two arguments, in which case each argument is compared to the argument to its right.

  1. (< 2 3) ==> T
  2. (> 2 3) ==> NIL
  3. (> 3 2) ==> T
  4. (< 2 3 4) ==> T
  5. (< 2 3 3) ==> NIL
  6. (<= 2 3 3) ==> T
  7. (<= 2 3 3 4) ==> T
  8. (<= 2 3 4 3) ==> NIL

To pick out the smallest or largest of several numbers, you can use the function **MIN** or **MAX**, which takes any number of real number arguments and returns the minimum or maximum value.

  1. (max 10 11) ==> 11
  2. (min -12 -10) ==> -12
  3. (max -1 2 -3) ==> 2

Some other handy functions are **ZEROP**, **MINUSP**, and **PLUSP**, which test whether a single real number is equal to, less than, or greater than zero. Two other predicates, **EVENP** and **ODDP**, test whether a single integer argument is even or odd. The P suffix on the names of these functions is a standard naming convention for predicate functions, functions that test some condition and return a boolean.