COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

MOVE G OF F OF A TO G OF F OF H
Example 65 CORRESPONDING Phrase
01 A 01 H
03 B 05 F
07 C 08 G
07 D 05 B
03 E 05 C
03 F 09 E
04 G 09 D
09 G
ROUNDED Phrase
When the number of fraction digits in the result of an arithmetic operation exceeds the number of
fraction digits in the receiving item, the excess digits must be deleted by either truncation or
rounding. Also, when one or more low-order integer positions in a receiving item are represented
by P in the item’s PICTURE character-string, equivalent digits in a result value must be deleted by
truncation or rounding.
When the ROUNDED phrase is not specified, excess digits are deleted by truncation; that is, the
digits are simply discarded. If rounding is specified, the absolute value of the retained portion of
the value is increased by 1 whenever the most significant digit of the excess is greater than or
equal to 5.
In these examples, the caret (^) represents the assumed decimal point:
Rounded ValuePICTURE Character-String of Receiving ItemActual Result
5^7159V9995^71489
7799PP7650^
3^149V993^141592654
SIZE ERROR Phrase
The size error condition indicates a problem in computation, such as a loss of precision. The SIZE
ERROR and NOT SIZE ERROR phrases of the ADD, COMPUTE, DIVIDE, MULTIPLY, and SUBTRACT
statements enable you to test whether the arithmetic operation caused the size error condition to
arise. You cannot test for the size error condition with an IF statement.
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.
244 Procedure Division