Common Phrases

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.

Arithmetic Statements

The arithmetic statements are the ADD, COMPUTE, DIVIDE, MULTIPLY and SUBTRACT statements. Common features are as follows:

  1. The data descriptions of the operands need not be the same; any necessary conversion and decimal point alignment are supplied throughout the calculation.
  2. The composite of operands is a hypothetical data item resulting from the superimposition of specified operands in a statement aligned on their decimal points.

    ANS85The composite of operands for ADD, DIVIDE, MULTIPLY and SUBTRACT statements must not contain more than 18 decimal digits.

    MFThere is no limit on the composite of operands.

Overlapping Operands

When a sending and a receiving item in a statement share a part of their storage areas,

ANS85yet are not defined by the same data description entry,

the result of the execution of such a statement is undefined.

MF 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.

MF 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.

Multiple Results in Arithmetic Statements

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:

  1. A statement which accesses all data items that are part of the initial evaluation of the statement, performs all arithmetic necessary to arrive at the result to be stored in the receiving items, and stores that result in a temporary storage location.
  2. A sequence of statements transferring or combining the value of this temporary location with each single resultant data item. These statements are considered to be written in the same left-to-right sequence in which the multiple results are listed.

    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.

Incompatible Data

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

ANS85or function definition

then the result of such a reference is undefined.

MF 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.

MFWhen an alphabetic field which contains non-alphabetic data is referenced, execution continues, but results may be undefined.

Signed Receiving Items

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.