Decimal division
The rules for a specific decimal division depend on whether the DEC31 option is in effect for the operation, whether p is greater than 15, and whether p' is greater than 15
The following table shows how the precision and scale of the result depend on these factors. In that table, the occurrence of "N/A" in a row implies that the indicated factor is not relevant to the case represented by the row.
DEC31 | p | p' | P | S |
---|---|---|---|---|
Not in effect | ≤15 | ≤15 | 15 | 15-(p-s+s') |
In effect | ≤15 | ≤15 | 31 | N-(p-s+s'),
where
|
N/A | >15 | ≤15 | 31 | N-(p-s+s'),
where
|
N/A | N/A | >15 | 31 | 15-(p-s+x), where
x is MAX(0,s'-(p'-15)) (See the following note) |
![Start of change](KC_ROOT/images/ddita/delta.gif)
- Minimum divide result scale
- If the calculated value of 's' is negative,
an error occurs. If a minimum divide result scale is specified, this
error does not occur.
The minimum scale is determined according to the following precedence:
- Static SQL
- The precompiler DEC option, if it is set with a non-zero scale.
- The DECIMAL ARITHMETIC field (DECARTH) on installation panel DSNTIP4, if it is set with a non-zero scale.
- The MINIMUM DIVIDE SCALE opaque subsystem parameter (MINDVSCL), if it is set to a value other than NONE.
- The MINIMUM DIVIDE SCALE field (DECDIV3) on installation panel DSNTIP4, if it is set to YES.
- Dynamic SQL
- The CURRENT PRECISION special register, if it is set with a non-zero scale.
- Either of the following cases:
- For a package that was bound with DYNAMICRULES RUN or if the USE FOR DYNAMICRULES field (DYNRULS) on installation panel DSNTIP4 is set to YES: The DECIMAL ARITHMETIC field (DECARTH) on installation panel DSNTIP4, if it is set with a non-zero scale.
- For all other cases: The precompiler DEC option, if it is set with a non-zero scale.
- The MINIMUM DIVIDE SCALE opaque subsystem parameter (MINDVSCL), if it is set to value other than NONE.
- The MINIMUM DIVIDE SCALE field (DECDIV3) on installation panel DSNTIP4, if it is set to YES
- SQL statements that are executed using SPUFI
- The value in DECIMAL ARITHMETIC (DECARTH).
The default value for both the precompiler DEC option and the CURRENT PRECISION special register is DECIMAL ARITHMETIC.
A minimum divide result scale of 3 can be specified using the MINIMUM DIVIDE SCALE field on the installation panel DSNTIP4. A minimum divide scale result between 1 and 9 can be specified using the DECIMAL ARITHMETIC OPTION of the form 'Dpp.s' where 'pp' is 15 or 31 and represents the precision and 's' represents the minimum divide scale, as a number between 1 and 9. Such a specification overrides the MINIMUM DIVIDE SCALE. When a minimum divide result scale is specified, the formula MAX(s,s'), where s represents the scale derived from the above table and s' represents the value specified by the minimum divide result scale, is applied and a new scale is derived. The newly derived scale is the scale of the result and overrides any scale derived using the table above.
![End of change](KC_ROOT/images/ddita/deltaend.gif)