COBOL Manual for TNS and TNS/R Programs

Procedure Division
HP COBOL Manual for TNS and TNS/R Programs522555-006
8-43
Common Features of Arithmetic Statements
Topics:
Common Features of Arithmetic Statements
Arithmetic Expressions
Arithmetic Precision
Common Features of Arithmetic Statements
This section describes the common features of the arithmetic statements, which are:
Data Conversion and Alignment
Composite of Operands
Intermediate Data Items
Multiple Results
Incompatible Data
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.