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

Data Conversion and Alignment
The data descriptions of the operands need not be the same; any necessary conversion and decimal
point alignment is supplied by the COBOL compiler throughout the calculation.
Composite of Operands
The maximum size of each arithmetic operand is 18 decimal digits, independent of any decimal
point. When the computer performs arithmetic, it must handle operands of different data descriptions.
To discuss the restrictions on arithmetic operations, the COBOL community coined the term
composite of operands.
The composite of operands for a given operation is a fictitious data item. It has as many positions
in its integer portion (to the left of the decimal point) as the operand that has the largest number
of integer positions, and as many positions in its fraction portion (to the right of the decimal point)
as the operand that has the largest number of fraction positions.
For example, in the data descriptions
01 A PIC S9(8)V9(4)
01 B PIC S9(2)V9(7)
01 C PIC S9(4)V9(9)
the composite of operands for an arithmetic operation involving only A, B, and C would have a
data description of S9(8)V9(9), or 17 digits.
The composite of operands for an arithmetic statement other than COMPUTE must not exceed a
size of 18 decimal digits. For arithmetic expressions or COMPUTE statements, the composite of
operands does not apply.
Intermediate Data Items
For each arithmetic operation, an intermediate data item holds the result value until that value is
either used as an operand in another operation or assigned to a receiving data item. The size of
the intermediate data item depends on the operations and data items used in the operation and
varies from 16 bits (about four digits) to 128 bits (about 39 digits). If the algebraic size of the
result exceeds the capacity of this intermediate data item, a binary, floating-point, intermediate
data item is used and the compiler issues warning 85. Because floating-point arithmetic has a
maximum precision of 16 digits and often is not exact, the result might be incorrect in the rightmost
digit or digits.
Multiple Results
The ADD, COMPUTE, DIVIDE, MULTIPLY, and SUBTRACT statements can have multiple results from
performing arithmetic necessary to arrive at the final result to be stored in the receiving item. During
execution, multiple results are the same as the results produced by a sequence of statements that
either combine the value of an intermediate data item with a single result or transfer the value to
a receiving item. These statements are in the same left-to-right order as that of the multiple results
in the actual statement.
For example, the results of the statement
ADD A B C TO C D (C) E
are equivalent to those of the statements
ADD A B C GIVING TEMP
ADD TEMP TO C
ADD TEMP TO D (C)
ADD TEMP TO E
TEMP is the intermediate data item. Any subscripts specified in a reference to a receiving item are
evaluated just prior to the assignment operation for that item.
258 Procedure Division