COBOL Manual for TNS/E Programs (H06.03+)
Procedure Division
HP COBOL Manual for TNS/E Programs—520347-003
8-50
Arithmetic Precision
ADD and SUBTRACT Statements
Each data item in an ADD or SUBTRACT statement, except the one after GIVING, is
called an addend. In the statement
ADD P Q R S T GIVING W
the addends are P, Q, R, S, and T. In the statement
ADD P Q R S T TO X Y
the addends are P, Q, R, S, T, X, and Y.
The number of accurate fraction digits maintained during evaluation is determined by
the addend having the greatest number of fraction digits. All remaining intermediate
result representation space is used for nonfraction digits. The computed result is
always completely accurate unless an internal overflow occurs, raising the size error
condition; therefore, all digits in the value assigned to a receiving data item are
accurate unless the size error condition occurs for that data item.
MULTIPLY Statement
The number of fraction digits in the product is the sum of the number of fraction digits
in the two operands. The number of accurate nonfraction digits in the product is the
sum of the nonfraction digits in the two operands. The computational method used
verifies that an internal overflow never occurs for a MULTIPLY statement; therefore, all
digits in the value assigned to a receiving data item are accurate unless the size error
condition occurs for that data item.
DIVIDE Statement
Because division is a rather complicated mathematical operation, and because the
computer is performing scaled integer arithmetic instead of floating-point arithmetic, the
rules stating the precision of HP COBOL division are somewhat complicated.
•
Effect of GIVING
When the GIVING phrase is present, a single quotient is computed. The
appropriate number of fraction digits in that quotient is determined from the
receiving operand having the greatest number of fraction digits.
When no GIVING phrase is present, a separate quotient is computed for each
receiving data item. Such a DIVIDE statement with multiple receiving data items is
exactly equivalent to a sequence of DIVIDE statements, each having a single
receiving data item and all having the same divisor. The appropriate number of
fraction digits in each quotient is determined from the corresponding receiving data
item.










