CURRENT DECFLOAT ROUNDING MODE
The CURRENT DECFLOAT ROUNDING MODE special register specifies the rounding mode that is used when DECFLOAT values are manipulated in dynamically prepared SQL statements.
The data type of the register is VARCHAR(128). The rounding
modes supported are:
- ROUND_CEILING
- Round toward +infinity. If all of the discarded digits are zero or if the sign is negative, the result is unchanged other than the removal of the discarded digits. Otherwise, the result coefficient is incremented by one (rounded up).
- ROUND_DOWN
- Round toward zero (truncation). The discarded digits are ignored.
- ROUND_FLOOR
- Round toward -infinity. If all of the discarded digits are zero or if the sign is positive, the result is unchanged other than the removal of the discarded digits. Otherwise, the sign is negative and the result coefficient is incremented by one.
- ROUND_HALF_DOWN
- Round to nearest; if equidistant, round down. If the discarded digits represent greater than half (0.5) of the value of a one in the next left position, then the result coefficient is incremented by one (rounded up). Otherwise, the discarded digits are ignored.
- ROUND_HALF_EVEN
- Round to nearest; if equidistant, round so that the final digit is even. If the discarded digits represent greater than half (0.5) of the value of a one in the next left position, then the result coefficient is incremented by one (rounded up). If they represent less than half, then the result coefficient is not adjusted (that is, the discarded digits are ignored). Otherwise (they represent exactly half), the result coefficient is unaltered if its rightmost digit is even, or incremented by one (rounded up) if its rightmost digit is odd (to make an even digit).
- ROUND_HALF_UP
- Round to nearest; if equidistant, round up. If the discarded digits represent greater than or equal to half (0.5) of the value of a one in the next left position, then the result coefficient is incremented by one (rounded up). Otherwise, the discarded digits are ignored.
- ROUND_UP
- Round away from zero. If all of the discarded digits are zero, the result is unchanged other than the removal of discarded digits. Otherwise, the result coefficient is incremented by one (rounded up).
The initial value of CURRENT DECFLOAT ROUNDING MODE in an
activation group is established by the first SQL statement that is
executed in the activation group.
- If the first SQL statement in an activation group is executed from an SQL program or SQL package, the CURRENT DECFLOAT ROUNDING MODE special register is set to the value of the DECFLTRND parameter.
- Otherwise, the initial value is ROUND_HALF_EVEN.
The DECFLTRND parameter on the CRTSQLxxx command or SET OPTION is used for static SQL statements.
Example
Set the host variable APPL_ROUND (VARCHAR(128)) to the current rounding mode.
SELECT CURRENT DECFLOAT ROUNDING MODE
INTO :APPL_ROUND
FROM SYSIBM.SYSDUMMY1