Numeric comparisons, Exponential notation, Numeric comparisons exponential notation – IBM SC34-5764-01 User Manual

Page 244

Advertising
background image

Numeric Comparisons

The comparison operators are listed in section “Comparison” on page 117. You can use any of these for
comparing numeric strings. However, you should not use ==, \==, ¬==, >>, \>>, ¬>>, <<, \<<, and ¬<< for
comparing numbers because leading and trailing blanks and leading zeros are significant with these
operators.

A comparison of numeric values is effected 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.

A quantity called fuzz affects the comparison of two numbers. This controls the amount by which two
numbers may differ before being considered equal for the purpose of comparison. The FUZZ value is set
by the instruction:

NUMERIC FUZZ

expression

;

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

The effect of FUZZ is to temporarily reduce the value of DIGITS by the FUZZ value for each numeric
comparison. That is, the numbers are subtracted under a precision of DIGITS minus FUZZ digits during
the comparison. Clearly the FUZZ setting must be less than DIGITS.

Thus if 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.

Example:

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"

*/

Exponential Notation

The preceding description of numbers describes “pure” numbers, in the sense that the character strings
that describe numbers can be very long. For example:

10000000000 * 10000000000

would give

100000000000000000000

and

.00000000001 * .00000000001

would give

0.0000000000000000000001

Numbers and Arithmetic

222

CICS TS for VSE/ESA: REXX Guide

Advertising