In the ANDxx, CABxx, CASxx, DOUxx, DOWxx, IFxx, ORxx, and WHENxx operations,
xx can be:
xx
Meaning
GT
Factor 1 is greater than factor 2.
LT
Factor 1 is less than factor 2.
EQ
Factor 1 is equal to factor 2.
NE
Factor 1 is not equal to factor 2.
GE
Factor 1 is greater than or equal to factor 2.
LE
Factor 1 is less than or equal to factor 2.
Blanks
Unconditional processing (CASxx or CABxx).
The compare operations test fields for the conditions specified in the
operations. These operations do not change the values of the fields. For COMP,
CABXX, and CASXX, the resulting indicators assigned in postions 71 and 76
are set according to the results of the operation. All data types may be compared
to fields of the same data type.
Remember the following when using the compare operations:
If numeric fields are compared, fields of unequal length are aligned at
the implied decimal point. The fields are filled with zeros to the left and/or
right of the decimal point making the field lengths and number of decimal
positions equal for comparison.
All numeric comparisons are algebraic. A plus (+) value is always greater
than a minus (-) value.
Blanks within zoned numeric fields are assumed to be zeros, if the FIXNBR(*ZONED)
control specification keyword or command parameter is used in the compilation
of the program.
If character, graphic, or UCS-2 fields are compared, fields of unequal
length are aligned to their leftmost character. The shorter field is filled
with blanks to equal the length of the longer field so that the field lengths
are equal for comparison.
Date fields are converted to a common format when being compared.
Time fields are converted to a common format when being compared.
An array name cannot be specified in a compare operation, but an array
element may be specified.
The ANDxx and ORxx operations can be used following DOUxx, DOWxx, IFxx,
and WHENxx.
When comparing a character, graphic, or UCS-2 literal with zero length
to a field (fixed or varying) containing blanks, the fields will compare equal.
If you want to test that a value is of length 0, use the %LEN built-in function.
See Figure 52 for examples.
Attention!
Note the following points, especially if you want to avoid unpredictable
results.
The order of the characters is not necessarily the same for
UCS-2 data as it is for character or graphic data; for example '2' is less
than 'A' in UCS-2, but it is greater than 'A' for a character comparison.
If a comparison operation involves implicit conversion to UCS-2, or if you
change some of your fields to have UCS-2 type instead of character or graphic
type, then you may notice that some less-than or greater-than comparisons
have different results than you expect.
All graphic and UCS-2 comparisons are done using the hexadecimal representation
of the data. The alternate sequence is not used.
If an alternate collating sequence (using the ALTSEQ{(*NONE | *SRC | *EXT)} keyword
on the Control specification) has been specified for the comparison of character
fields, the comparands are converted to the alternate sequence and then compared.
If *HIVAL or *LOVAL is used in the comparison, the alternate collating sequence
may alter the value before the compare operation. Note that if either comparand
is defined with the ALTSEQ(*NONE) keyword on the definition specification,
the alternate collating sequence is not used.
When comparing
a basing pointer to *NULL (or to a basing pointer with value *NULL), the only
comparisons that produce predictable results are for equality and inequality.
Comparing pointers for less-than or greater-than produces predictable
results only when the pointers point to addresses in contiguous storage. For
example, all pointers are set to addresses in one *USRSPC, or all pointers
are set to the addresses of array elements in one array.
When procedure pointer fields are compared for anything except equality
or inequality, the results will be unpredictable.
Because of the way float values are stored, they should not be compared
for equality or inequality. Instead, the absolute value of the difference
between the two values should be compared with a very small value.