COBOL Manual for TNS/E Programs (H06.03+)
Procedure Division
HP COBOL Manual for TNS/E Programs—520347-003
8-51
Arithmetic Precision
•
Effect of Decimal Point Placement
Under the mathematical rules for division, fraction digits in the divisor cause the
significant digit positions of the quotient to appear shifted to the left with respect to
the significant digit positions of the dividend. This corresponds to moving the
decimal point of the dividend to the right the same number of positions as would be
necessary to make the divisor an integer:
1.00/0.3 = 10.0/03 = 03.3
Put another way, each divisor fraction digit cancels a trailing digit position in the
dividend, which then reappears as a leading digit position in the quotient. This
causes a problem when the actual dividend has fewer fraction digits than the sum
of the number of digits in the divisor’s fraction and the number of digits in the
appropriate quotient’s fraction.
Suppose you want to divide two data items described as:
DIVIDEND PICTURE 9(10)v9(5) USAGE DISPLAY
DIVISOR PICTURE 9(4)v9(7) USAGE DISPLAY
If the computer aligns them by scaling each up by 7 decimal places, it has to
extend the dividend’s fraction with 2 additional digit positions filled with zeros. It
would be dividing a 17-digit integer by an 11-digit integer.
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.
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.










