COBOL Manual for TNS and TNS/R Programs
Procedure Division
HP COBOL Manual for TNS and TNS/R Programs—522555-006
8-51
Arithmetic Precision
Because the sum of the number of actual dividend digits and the number of
appended zero digits cannot exceed 36, there are very few combinations of
operands in a DIVIDE statement for which it is impossible to append enough zeros.
•
Size Error
All digits in the value assigned to the receiving data item are accurate unless either
the size error condition occurs for that data item or at least one trailing digit is
fictitious (that is, set to 0 because it was not generated by the division operation).
Arithmetic Expressions
HP COBOL maintains intermediate results during the evaluation of arithmetic
expressions. Arithmetic expressions occur only in the COMPUTE statement, the
EVALUATE statement, the relation condition, the sign condition, the reference modifier,
the parameters of the ENTER statement, and function arguments.
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:
Note. The precision of COBOL arithmetic computation has limitations. The COMPUTE
statement is particularly sensitive. Use of an appropriate sequence of the ADD, SUBTRACT,
MULTIPLY, and DIVIDE statements permits you to attain the precision you desire, provided
that the PICTURE clauses describing the operands do not imply potential values of
exaggerated significance. There is no guarantee that the result of an arithmetic expression will
be the same in different implementations.
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.