COBOL Manual for TNS and TNS/R Programs

Procedure Division
HP COBOL Manual for TNS and TNS/R Programs522555-006
8-55
Simple Conditions
Numeric Comparisons
Numeric comparisons are made with respect to the algebraic values of the
operands. The number of digits present in the representation of an operand is not
significant. Comparison of numeric operands is permitted regardless of the manner
in which their usage is described. Unsigned numeric operands are considered
positive for purposes of comparison. Zero is considered a unique value regardless
of its sign.
Nonnumeric Comparisons
For nonnumeric operands, or one numeric and one nonnumeric operand, a
comparison is made with respect to the program collating sequence (see OBJECT-
COMPUTER Paragraph).
°
One operand is numeric:
°
The numeric operand must be a numeric literal or a reference to a numeric
data item; therefore, it cannot be an arithmetic expression. COBOL
requires the operand to be an integer and, if a data item, to have DISPLAY
usage. HP COBOL removes both of these restrictions.
°
When the nonnumeric operand is either an elementary data item or a
nonnumeric literal, the numeric operand is handled as though it were
moved to an elementary alphanumeric data item, and the value of this item
were then compared to the nonnumeric operand. The size of this
conceptual data item is the same as the number of digit positions in the
numeric operand. The numeric operand is handled as if it were an
unsigned integer; therefore any sign or assumed decimal point is deleted
by the conceptual move, and no COMPUTATIONAL items are converted to
usage DISPLAY.
°
When the nonnumeric operand is a data structure, the numeric operand is
handled as though it were moved to a data structure, and the value of this
item were then compared to the nonnumeric operand. The size of this
conceptual data item is the same as the number of character positions
occupied by the numeric operand. Because the operand is handled as if it
were alphanumeric, the sign of the numeric operand (if any) is not deleted
by the conceptual move, and no COMPUTATIONAL usage items are
converted to DISPLAY usage.
°
Operand size
The size of an operand is the total number of characters it contains. Operands
can be of equal or unequal size.