COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
create intermediate data items as it evaluates the expression. Arithmetic expressions occur only in
the COMPUTE, ENTER, and EVALUATE statements, the relation and sign conditions, function
arguments, and in reference modification.
In discussing precision, we ignore the presence of a scale factor or of any decimal point; the
arithmetic processing records and handles these elements separately. After the computation is
performed with integral values, the decimal point and scale factor (if any) are then provided for
the result.
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.
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.
262 Procedure Division










