COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

exactly, the result might be slightly larger or smaller than the exact number. You might have to use
individual operations or revise the expression to guarantee accurate results.
To obtain the maximum accuracy in an arithmetic expression that involves a division, use parentheses
or revise the expression as necessary to assure that the division is the last operation performed.
For example, you can rewrite the expression “a / b * c" as "(a * c) / b".
When a conditional expression compares a variable and an expression, the number of decimal
places carried for the variable is used for the number of decimal places carried for the expression.
When a conditional expression compares two expressions, the compiler determines the smallest
number of decimal places suitable for each of the expressions and then uses the larger of those
numbers of decimal places.
In a COMPUTE statement, the number of decimal places of the composite of operands of the
receiving fields is the number of decimal places of the expression.
If ROUNDED is specified on any operand, one additional decimal position is used in the
computation, then the rounding is applied to the result.
Conditional Expressions
Many different statements include conditional expressions. A conditional expression is a syntactically
correct combination of simple conditions, logical operators, and parentheses that can be evaluated
to a truth value. The truth value determines which of two paths of control the object program takes.
The simplest form of a conditional expression is a simple condition. Complex conditions are
combinations of simple conditions and any of the logical operators NOT, AND, and OR. COBOL
allows you to abbreviate sequences of complex relation conditions. You can use balanced sets of
parentheses to control or clarify the order of evaluation within a conditional expression.
Topics:
Simple Conditions
Complex Conditions
Abbreviated Combined Relation Conditions
Condition Evaluation Rules
Simple Conditions
A simple condition has a truth value of TRUE or FALSE. Enclosing a simple condition within
parentheses does not affect its truth value. The simple conditions are:
Relation Conditions in General
Relation Conditions With Nonpointer Operands
Relation Conditions With Pointer Operands
Class Conditions
Condition-Name Conditions (Conditional Variables)
Switch-Status Conditions
Sign Conditions
Relation Conditions in General
A relation condition causes a comparison of two operands. The relation condition has a truth value
of TRUE if the relation exists between the operands; otherwise, it has a truth value of FALSE.
Conditional Expressions 265