Rational Developer for System z
COBOL for Windows, Version 7.5, 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

The collating sequence used for comparison is determined by the PROGRAM COLLATING SEQUENCE clause in the OBJECT-COMPUTER paragraph and the setting of the COLLSEQ compiler option.

If the PROGRAM COLLATING SEQUENCE clause is specified with an alphabet-name of STANDARD-1, STANDARD-2, or EBCDIC, the COLLSEQ compiler option is ignored. The collating sequence is the one associated with the specified alphabet-name. The comparison proceeds as described below for Standard comparison (page ***).

If the PROGRAM COLLATING SEQUENCE clause is not specified or is specified with an alphabet-name of NATIVE, the method of comparison is determined by the COLLSEQ compiler option:

If the PROGRAM COLLATING SEQUENCE clause is specified with an alphabet-name that references a collating sequence defined by literals, the collating sequence is determined by the order of the specified literals and the sequence indicated by the COLLSEQ compiler option, as described for the ALPHABET clause. The comparison proceeds as described below for Standard comparison (page ***).

Standard comparison

A standard comparison is any comparison that is not based on a locale. The standard comparison method depends on whether the operands to be compared are of equal length or unequal length.

If the operands are of unequal length, the comparison proceeds as though the shorter operand were padded on the right with appropriate space characters 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 character positions in the two operands, starting from the leftmost position, until either unequal characters are encountered or the rightmost character position is reached, whichever comes first. The operands are determined to be equal if all corresponding characters are equal.

The first-encountered unequal character in the operands is compared to determine the relation of the operands. The operand that contains the character with the higher collating value is the greater operand.


Terms of use | Feedback

Copyright IBM Corporation 1996, 2008.
This information center is powered by Eclipse technology. (http://www.eclipse.org)