In the statement descriptions several phrases appear frequently:
In the following paragraphs, the term "resultant-identifier" refers to that identifier associated with the result of an arithmetic operation.
The arithmetic statements are the ADD, COMPUTE, DIVIDE, MULTIPLY and SUBTRACT statements. Common features are as follows:
The composite of operands is a hypothetical data item resulting from the superimposition of specified operands in a statement aligned on their decimal points.
The composite of operands for ADD, DIVIDE, MULTIPLY and SUBTRACT statements
must not contain more than 18 decimal digits.
There is no limit on the composite of operands.
When a sending and a receiving item in a statement share a part of their storage areas,
yet are not defined by the same data description entry,
the result of the execution of such a statement is undefined.
Overlapping moves are detected
at compile time only when the MOVE verb is used and neither operand uses reference
modification or subscripting. Forward overlapping moves result in a warning
message, if you set the Compiler directive WARNING"3". Any other types result
in flagging messages, if you set the Compiler directive FLAG"dialect", where
"dialect" is anything but OSVS. Other operations resulting in sending and
receiving items sharing the same memory are not detected.
Although portability of COBOL source code is only guaranteed when there
are no overlapping MOVE statements, this COBOL system does allow such statements.
The behavior of such statements is sensitive to the BYTE-MODE-MOVE Compiler
directive.
The ADD, COMPUTE, DIVIDE, MULTIPLY and SUBTRACT statements can have multiple results. Such statements behave as though they had been written in the following way:
The result of the statement:
ADD a, b, c TO c, d (c), e
is equivalent to:
ADD a, b, c GIVING temp ADD temp TO c ADD temp TO d (c) ADD temp TO e
and the result of the statement:
MULTIPLY a(i) BY i, a(i)
is equivalent to:
MOVE a(i) to temp MULTIPLY temp by i MULTIPLY temp BY a(i)
where temp is an intermediate result item provided by your COBOL system.
Except for the class condition (see the topic Class Condition), when the contents of a data item are referenced in the Procedure Division and the contents of that data item are not compatible with the class specified for that data item by its PICTURE clause
or function definition
then the result of such a reference is undefined.
The results of referencing a numeric
field that contains nonnumeric, or otherwise invalid data, are undefined.
Such conditions may be detected, and give an error at run-time. This behavior
is affected by the F RTS switch.
When an alphabetic field which contains non-alphabetic data is referenced,
execution continues, but results may be undefined.
When the receiving item in an arithmetic statement or a MOVE statement is a signed numeric or a signed numeric-edited item, the sign is moved into the receiving item independently of any truncation of the absolute numeric data. It is possible, therefore, for the numeric value to be zero but for the sign to be negative.