COBOL Manual for TNS and TNS/R Programs
Procedure Division
HP COBOL Manual for TNS and TNS/R Programs—522555-006
8-24
SIZE ERROR Phrase
The situations that cause the size error condition are:
•
Exponentiation
If the program attempts to raise zero to the zero power, or if no real number exists
as the result of the exponentiation, the arithmetic operation is terminated and the
size error condition arises.
•
Division
If the program attempts to divide any value by zero, the arithmetic operation is
terminated and the size error condition arises.
•
Overflow
If, after decimal point alignment, the absolute value of a result exceeds the largest
value that can be contained in the receiving data item, a size error condition arises.
The size error condition applies to intermediate and final results. If the ROUNDED
phrase is specified, rounding occurs before checking for a size error. When a size error
condition occurs, the subsequent action depends on whether the SIZE ERROR and
NOT SIZE ERROR phrases are specified.
Usage Considerations:
•
SIZE ERROR Phrase and TRAP2 Directive
The SIZE ERROR phrase catches size errors in COMPUTATIONAL arithmetic that
the TRAP2 directive (which is the default) does not; however, the SIZE ERROR
phrase generates more code than the TRAP2 directive does.
In Example 8-10, C=A+B causes a size error that the TRAP2 directive does not
catch, but that the SIZE ERROR phrase does catch.
Note. The NMCOBOL compiler, which has traps set by default, ignores the TRAP2
directive and issues a warning.