Using the "Result Decimal Position" Precision Rules
The "Result Decimal Position" precision rule means that the precision of
a decimal intermediate will be computed such that the number of decimal places
will never be reduced smaller than the number of decimal positions of the
result of the assignment. This is specified by:
EXPROPTS(*RESDECPOS) on the Control
Specification. Use this to specify this behaviour for an entire module.
Operation code extender R specified for a free-form operation.
Result Decimal Position rules apply in the following circumstances:
Result Decimal Position precision rules apply only to packed decimal intermediate
results. This behaviour does not apply to the intermediate results of operations
that have integer, unsigned, or float results.
Result Decimal Position precision rules apply only where there is an assignment
(either explicit or implicit) to a decimal target (packed, zoned, or binary).
This can occur in the following situations:
For an EVAL statement, the minimum decimal places is given by
the decimal positions of the target of the assignment and applies to the expression
on the right-hand side of the assignment. If half-adjust also applies to the
statement, one extra digit is added to the minimum decimal positions (provided
that the minimum is less than 63).
For a RETURN statement, the minimum decimal places is given by
the decimal positions of the return value defined on the PI specification
for the procedure. If half-adjust also applies to the statement, one extra
digit is added to the minimum decimal positions (provided that the minimum
is less than 63).
For a VALUE or CONST parameter, the minimum decimal
positions is given by the decimal positions of the formal parameter (specified
on the procedure prototype) and applies to the expression specified as the
passed parameter.
For built-in function %DEC and %DECH with explicit length
and decimal positions specified, the minimum decimal positions is given by
the third parameter of the built-in function and applies to the expression
specified as the first parameter.
The minimum number of decimal positions applies to the entire sub-expression
unless overridden by another of the above operations. If half-adjust is specified
(either as the H operation code extender, or by built-in function %DECH), the number of decimal positions of the intermediate result is
never reduced below N+1, where N is the number of decimal positions of the result.
The Result Decimal Position rules do not normally apply to conditional
expressions since there is no corresponding result. (If the comparisons must
be performed to a particular precision, then %DEC or %DECH must
be used on the two arguments.)
On the other hand, if the conditional expression
is embedded within an expression for which the minimum decimal positions are
given (using one of the above techniques), then the Result Decimal Positions
rules do apply.