next up previous

12.1.13 Comparing Numbers for Equality

The = function returns the symbol TRUE if its first argument is equal in value to all its subsequent arguments, otherwise it returns the symbol FALSE. Note that = compares only numeric values and will convert integers to floats when necessary for comparison.

Syntax

(= <numeric-expression> <numeric-expression>+)

Example

    CLIPS> (= 3 3.0)
    TRUE
    CLIPS> (= 4 4.1)
    FALSE


Portability Note

Because the precision of floating point numbers varies from one machine to another, it is possible for the numeric comparison functions to work correctly one machine and incorrectly on another. In fact, you should be aware, even if code is not being ported, that roundoff error can cause erroneous results. For example, the following expression erroneously returns the symbol TRUE because both numbers are rounded up to 0.6666666666666666667.

    CLIPS> (= 0.66666666666666666666 0.66666666666666666667)
    TRUE
    CLIPS>


next up previous