Comparison of Nonnumeric Operands

For nonnumeric operands, or one numeric and one nonnumeric operand, a comparison is made with respect to the program's collating sequence of characters.

If one of the operands is numeric, it must be an integer data item or an integer literal. The numeric operand is treated as though it were moved to an alphanumeric data item of the same size as the numeric data item. This alphanumeric item is then used in the comparison. A non-integer numeric operand may not be compared to a nonnumeric operand.

When the comparison is performed, the shorter operand (if any) is treated as though it were extended on the right with spaces to make the operands of equal size. Characters are then compared in corresponding positions starting from the left end and continuing until either a pair of unequal characters is encountered or the right end of the operand is reached. If all the characters are the same, then the operands are considered equal. Otherwise, the operand with the smaller character in the first unequal pair is considered less than the other operand.