Numeric Comparisons

The comparison operators are listed in Comparison. You can use any of them for comparing numeric strings. However, you should not use ==, \==, ¬==, >>, \>>, ¬>>, <<, \<<, and ¬<< for comparing numbers because leading and trailing whitespace characters and leading zeros are significant with these operators.

Numeric values are compared by subtracting the two numbers (calculating the difference) and then comparing the result with 0. That is, the operation:

A ? Z

where ? is any numeric comparison operator, is identical with:

(A - Z) ? "0"

It is, therefore, the difference between two numbers, when subtracted under Rexx subtraction rules, that determines their equality.

Fuzz affects the comparison of two numbers. It controls how much two numbers can differ and still be considered equal in a comparison. The FUZZ value is set by the following instruction:

>>-NUMERIC FUZZ--+------------+--;-----------------------------><

expression must result in a positive whole number or zero. The default is 0.

Fuzz is to temporarily reduce the value of DIGITS. That is, the numbers are subtracted with a precision of DIGITS minus FUZZ digits during the comparison. The FUZZ setting must always be less than DIGITS.

If, for example, DIGITS = 9 and FUZZ = 1, the comparison is carried out to 8 significant digits, just as though NUMERIC DIGITS 8 had been put in effect for the duration of the operation.


Numeric digits 5
Numeric fuzz 0
say  4.9999 = 5     /* Displays "0"    */
say  4.9999 < 5     /* Displays "1"    */
Numeric fuzz 1
say  4.9999 = 5     /* Displays "1"    */
say  4.9999 < 5     /* Displays "0"    */