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:

  1. EXPROPTS(*RESDECPOS) on the Control Specification. Use this to specify this behaviour for an entire module.
  2. Operation code extender R specified for a free-form operation.

Result Decimal Position rules apply in the following circumstances:

  1. 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.
  2. 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:
    1. 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).
    2. 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).
    3. 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.
    4. 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.

  3. 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.



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