Rational Developer for System z
Enterprise COBOL for z/OS, Version 4.1, Language Reference


Alphanumeric comparisons

An alphanumeric comparison is a comparison of the single-byte character values of two operands.

When one of the operands is neither class alphanumeric nor class alphabetic, that operand is processed as follows:

Comparison of two alphanumeric operands

Alphanumeric comparisons are made with respect to the collating sequence of the character set in use as follows:

  • For the EBCDIC character set, the EBCDIC collating sequence is used.
  • For the ASCII character set, the ASCII collating sequence is used. (See EBCDIC and ASCII collating sequences.)
  • When the PROGRAM COLLATING SEQUENCE clause is specified in the object-computer paragraph, the collating sequence used is the one associated in the special-names paragraph with the specified alphabet-name.

The size of each operand is the total number of character positions in that operand; the size affects the result of the comparison. There are two cases to consider:

Operands of equal size
Characters in corresponding positions of the two operands are compared, beginning with the leftmost character and continuing through the rightmost character.

If all pairs of characters through the last pair evaluate as equal, the operands are equal.

If a pair of unequal characters is encountered, the characters are tested to determine their relative positions in the collating sequence. The operand that contains the character higher in the sequence is considered the greater operand.

Operands of unequal size
If the operands are of unequal size, the comparison is made as though the shorter operand were extended to the right with enough spaces to make the operands equal in size.

The higher collating value is determined using the hexadecimal value of characters.


Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)