National comparisons
A national comparison is a comparison of the national character value of two operands of class national.
When the relation condition specifies an operand that is not class national, that operand is converted to a data item of category national before the comparison. The following list describes the conversion of operands to category national.
- DBCS
- A DBCS operand is treated as though it were moved to a temporary data item of category national of the same length as the DBCS operand. DBCS characters are converted to the corresponding national characters. The source code page used for the conversion is the one in effect for the CODEPAGE compiler option when the source code was compiled.
- Alphabetic, alphanumeric, alphanumeric-edited, and numeric-edited with usage DISPLAY
- The operand is treated as though it were moved to a temporary data item of category national of the length needed to represent the number of character positions in that operand. Alphanumeric characters are converted to the corresponding national characters. The source code page used for the conversion is the one in effect for the CODEPAGE compiler option when the source code was compiled.
- Numeric integer
- A numeric integer operand is treated as though it were moved to a temporary data item of category alphanumeric of a length the same as the number of digits in the integer. The unsigned value is used. The resulting temporary data item is then converted as an alphanumeric operand.
- External floating-point
- A display floating-point
item is treated as though
it were a data item of category alphanumeric, rather than as a numeric
value, and then converted as an alphanumeric operand.
A national floating-point item is treated as though it were a data item of category national, rather than as a numeric value.
The implicit moves for the conversions are carried out in accordance with the rules of the MOVE statement.
The resulting category national data item is used in the comparison of two national operands.
Comparison of two national operands
If the operands are of unequal length, the comparison proceeds as though the shorter operand were padded on the right with the default national space character (NX'0020') to make the operands of equal length. The comparison then proceeds according to the rules for the comparison of operands of equal length.
If the operands are of equal length, the comparison proceeds by comparing corresponding national character positions in the two operands, starting from the leftmost position, until either unequal national characters are encountered or the rightmost national character position is reached, whichever comes first. The operands are determined to be equal if all corresponding national characters are equal.
The first-encountered unequal national character in the operands is compared to determine the relation of the operands. The operand that contains the national character with the higher collating value is the greater operand.
The higher collating value is determined using the hexadecimal value of characters.
The PROGRAM COLLATING SEQUENCE clause has no effect on comparisons of national operands.