Compiler Calculation of Intermediate Results
The number of integer places in an ir is calculated as follows:
- If an operand in this statement is a data-name, the value used for the data-name is equal to the numerical value of the PICTURE for the data-name (that is, PICTURE 9V99 has the value 9.99).
- If an operand is a literal, the literal is treated as though it had a PICTURE, and the numerical value of the PICTURE is used (that is, the literal +127.3 has an implied PICTURE S999V9).
- If an operand is an intermediate result, the PICTURE determined for the intermediate result in a previous operation is used. The numerical value of that PICTURE is used.
- If the operation is division:
- If op2 is a data-name, the value used for op2 is the minimum nonzero value of the digit in the PICTURE for the data-name (that is, PICTURE 9V99 has the value 0.01).
- If op2 is an intermediate result, the intermediate result is treated as though it had a PICTURE, and the minimum nonzero value of the digits in this PICTURE is used.
Once the maximum value of the ir has been determined by the above procedures, i is set equal to the number of integers in the maximum value.
The number of decimal places contained in an ir is calculated as:
| Operation | Integer Places | Decimal Places |
|---|---|---|
| + or - | (i1 or i2) + 1, whichever is greater | d1 or d2, whichever is greater |
| * | i1 + i2 | d1 + d2 |
| / | i2 + d1 | (d2 - d1) or dmax, whichever is greater |
| ** | When i2 equals 0, |
dmax if op2 is nonintegral or a |
| Note:
|
||
You must define the operands of any arithmetic statements with enough decimal places to give the desired accuracy in the final result.
Table 2 indicates the action of the compiler when handling intermediate results for fixed-point numbers.
| Value of i + d2 | Value of d | Value of i + dmax | Action Taken |
|---|---|---|---|
| < MAXLENGTH1 |
Any Value | Any Value | i integer and d decimal places are carried for ir. |
| > MAXLENGTH3 | < dmax |
Any Value | MAXLENGTH - d integer and d decimal places are carried for ir. |
| > dmax | < MAXLENGTH |
i integer and MAXLENGTH - i decimal places are carried for ir. | |
| > MAXLENGTH | MAXLENGTH - dmax integer and dmax decimal places are carried for ir. | ||
| Note:
|
|||
If you think an intermediate result field might exceed MAXLENGTH digits, you can use floating-point operands (COMP-1 and COMP-2) to avoid truncation.
34 decimal digits, when the arithmetic mode compiler
option *EXTEND31FULL or PROCESS statement option EXTEND31FULL is specified.