ILE COBOL Language Reference


Calculating Precision of Intermediate Results

The compiler uses algorithms to determine the number of integer and decimal places reserved for intermediate results.

In the following discussion of how the compiler determines the number of integer and decimal places reserved for intermediate results, these abbreviations are used:

i
The number of integer places carried for an intermediate result.

d
The number of decimal places carried for an intermediate result.

ROUNDED
If the ROUNDED option is used, one more integer or decimal place might be added for accuracy, if necessary. Only the final results are rounded; the intermediate results are not rounded. 62 digits is the maximum number of digits that can be accurately rounded.

dmax
In a particular statement, the largest of:

inner-dmax
The inner-dmax for a function is the largest of:

outer-dmax
The number that determines how a function result contributes to operations outside of its own evaluation (for example if the function is an operand in an arithmetic expression or an argument to another function).

op1
The first operand in a generated arithmetic statement. For division, op1 is the divisor.

op2
The second operand in a generated arithmetic statement. For division, op2 is the dividend.

i1,i2
The number of integer places in op1 and op2, respectively.

d1,d2
The number of decimal places defined for op1 and op2, respectively.

ir
Intermediate result field obtained from the processing of a generated arithmetic statement or operation. Intermediate results are represented by ir1, ir2, and so on. Successive intermediate results may share the same memory location.

Below we use a COMPUTE statement to demonstrate the use of intermediate results in an arithmetic expression. In this case, the following statement:

  COMPUTE Y = A + B * C - D / E + F ** G

is replaced by

F ** G
yielding ir1
MULTIPLY B BY C yielding ir2
DIVIDE E INTO D yielding ir3
ADD A TO ir2 yielding ir4
SUBTRACT ir3 FROM ir4 yielding ir5
ADD ir5 TO ir1 yielding Y


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]