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

Procedure Division
HP COBOL Manual for TNS/E Programs520347-003
8-52
Arithmetic Precision
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:
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.
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 ...
Abbreviation Description
IR Number of integer places carried for an intermediate result.
DR Number of decimal places carried for an intermediate result.
OP1 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.
OP2 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.
OPR 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.
Operation
Decimal Places (Worst-Case Precision)
DR is the greater/greatest of … IR is the lesser of …
OP1 + OP2
OP1 - OP2
D1 and D2 (The greater of I1 and I2) + 1) and
(36 - DR)
OP1
* OP2 D1 and D2 (I1 + I2) and (36 - DR)
OP1 / OP2 D1 - D2, the D of the composite of
all the result fields, and 1
(I1 + D2) and (36 - DR)
OP1
** OP2 D1 or D2 (The greater of I1 or I2) and (36 - DR)
Note. If (I1+D2+DR) > 36, the compiler uses floating-point arithmetic (and issues warning 85).