COBOL Manual for TNS and TNS/R Programs

Procedure Division
HP COBOL Manual for TNS and TNS/R Programs522555-006
8-49
Arithmetic Precision
The largest value HP COBOL can store is the unsigned COMPUTATIONAL-5 value
18,446,744,073,709,551,615.
The largest value HP COBOL can store associated with a DISPLAY or
COMPUTATIONAL data item (independent of any decimal point or scale factor) is the
20-digit number which is the highest value for an unsigned 64-bit number.
In evaluating arithmetic expressions, COBOL can manipulate intermediate values
having up to 128 bits (about 39 digits).
These topics explain arithmetic precision as it applies to:
SIZE ERROR
ADD and SUBTRACT Statements
MULTIPLY Statement
DIVIDE Statement
Arithmetic Expressions
SIZE ERROR
As explained in SIZE ERROR Phrase, the size error condition indicates a problem in
computation. It arises when an arithmetic overflow occurs or when a program attempts
to divide by zero, raise zero to the zero power, or raise a negative number to a power
that produces other than a real number value. If no SIZE ERROR clause is present in
the statement where the condition arises, the process can terminate abnormally with
an arithmetic overflow or it can store invalid values into result items (mainly in items of
USAGE COMPUTATIONAL).
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.