When an arithmetic statement has multiple results, execution conceptually
proceeds as follows:
- The statement performs all arithmetic operations to find the result to
be placed in the receiving items, and stores that result in a temporary location.
- A sequence of statements transfers or combines the value of this temporary
result with each single receiving field. The statements are considered to
be written in the same left-to-right order as the multiple results are listed.
For example, executing the following statement:
ADD A, B, C, TO C, D(C), E.
is equivalent to executing the following series of statements:
ADD A, B, C GIVING TEMP.
ADD TEMP TO C.
ADD TEMP TO D(C).
ADD TEMP TO E.
In the above example, TEMP is a compiler-supplied temporary result field.
When the addition operation for D(C) is performed, the subscript C contains
the new value of C.
Note: Intermediate results generated during
the execution of arithmetic statements are system-specific and can affect
program portability. Use of the individual arithmetic statements ADD, SUBTRACT,
MULTIPLY, and DIVIDE, rather than COMPUTE, reduces the risk of getting inconsistent
results.