The SET CURRENT DECFLOAT ROUNDING MODE statement changes
the value of the CURRENT DECFLOAT ROUNDING MODE special register.
Invocation
This statement can be embedded
in an application program or issued interactively. It is an executable
statement that can be dynamically prepared.
Syntax

.- = -.
>>-SET CURRENT DECFLOAT ROUNDING MODE--+-----+------------------>
>----+-ROUND_CEILING---+---------------------------------------><
+-ROUND_DOWN------+
+-ROUND_FLOOR-----+
+-ROUND_HALF_DOWN-+
+-ROUND_HALF_EVEN-+
+-ROUND_HALF_UP---+
+-ROUND_UP--------+
+-variable--------+
'-string-constant-'
Description
- 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 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.
This
rounding mode is not recommended when creating a portable application
since it is not supported by the IEEE draft standard for floating-point
arithmetic.
- 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).
This
rounding mode is not recommended when creating a portable application
since it is not supported by the IEEE draft standard for floating-point
arithmetic.
- string-constant
- A character constant that contains a specification of the rounding
mode.
- variable
- Specifies a variable which contains the value for the CURRENT
DECFLOAT ROUNDING MODE. The content is not folded to uppercase.
The
variable:
- Must be a character-string or Unicode graphic-string variable.
- Must not be followed by an indicator variable.
- Must contain one of the seven rounding mode keywords.
- Must be padded on the right with blanks if the variable is fixed
length.
Notes
Transaction considerations: The SET CURRENT DECFLOAT
ROUNDING MODE statement is not a commitable operation. ROLLBACK has
no effect on the CURRENT DECFLOAT ROUNDING MODE.
Initial
CURRENT DECFLOAT ROUNDING MODE: 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.
CURRENT DECFLOAT ROUNDING MODE scope is activation group.
Examples
Example 1: Set the CURRENT
DECFLOAT ROUNDING MODE special register to ROUND_DOWN using a string
constant and using a keyword.
SET CURRENT DECFLOAT ROUNDING MODE = 'ROUND_DOWN'
SET CURRENT DECFLOAT ROUNDING MODE = ROUND_DOWN