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

The evaluation of an arithmetic expression is the result of the evaluation of a sequence of
intermediate results. The maximum number of digits held for an intermediate result is 36. If this
number is exceeded, the compiler might use binary floating-point arithmetic (and issue warning
85). The size error condition applies to both final results and intermediate results.
These abbreviations are used to explain intermediate operations:
DescriptionAbbreviation
Number of integer places carried for an intermediate result.IR
Number of decimal places carried for an intermediate result.DR
First operand in an arithmetic expression, which has the form 9(I1)V9(D1), where I1
is the number of integer places carried and D1 is the number of decimal places
carried for the first operand.
OP1
Second operand in an arithmetic expression, which has the form 9(I2)V9(D2), where
I2 is the number of integer places carried and D2 is the number of decimal places
carried for the second operand.
OP2
Desired result, which has the form 9(IR)V9(DR), where IR is the number of places
carried for the integer result, and DR is the number of places carried for the decimal
result.
OPR
The number of decimal places in the intermediate result (DR) is chosen first, then the number of
integer places in the intermediate result is determined from that and the characteristics of the two
operands.
HP COBOL guarantees that the mathematical significance of results will be at least as good as
application of these rules implies.
Decimal Places (Worst-Case Precision)
IR is the lesser of DR is the greater/greatest of Operation
(The greater of I1 and I2) + 1) and (36
- DR)
D1 and D2OP1 + OP2 OP1 - OP2
(I1 + I2) and (36 - DR)D1 and D2OP1 * OP2
(I1 + D2) and (36 - DR)D1 - D2, the D of the composite of all
the result fields, and 1
OP1 / OP2
(The greater of I1 or I2) and (36 - DR)D1 or D2OP1 ** OP2
NOTE: If (I1+D2+DR) > 36, the compiler uses floating-point arithmetic (and issues warning 85).
When an arithmetic expression involves a division operation, the intermediate results are evaluated
in these steps:
1. The actual division
2. The adjustment of that result for use in further computations
Therefore, in each of these instances of the arithmetic expression A1/A2+A3*A4,
COMPUTE AX = A1/A2 + A3 * A4
IF A1/A2 + A3 * A4 LESS THAN AX GO TO ...
the division is performed before further evaluation of either of the preceding statements. If the
division operation is not the last operation in the expression and the divisor is not 2, 4, 5, 8, or a
power of 10, the division is carried out to 36 digits. As many fractional digits as possible are kept.
This number can be truncated depending on subsequent operations. In some cases adjustment is
not possible, so the compiler uses binary floating-point arithmetic (and issues warning 85). Since
the precision of floating-point arithmetic is 16 digits and numbers cannot always be represented
264 Procedure Division