SET CURRENT DECFLOAT ROUNDING MODE

The SET CURRENT DECFLOAT ROUNDING MODE statement assigns a value to the CURRENT DECFLOAT ROUNDING MODE special register. The special register sets the default rounding mode that is used with decimal floating point values (DECFLOAT).

Invocation

This statement can be embedded in an application program or issued interactively. It is an executable statement that can be dynamically prepared.

Authorization

None required.

Syntax

                                       .-=-.                        
>>-SET CURRENT DECFLOAT ROUNDING MODE--+---+--+-ROUND_CEILING---+-><
                                              +-ROUND_DOWN------+   
                                              +-ROUND_FLOOR-----+   
                                              +-ROUND_HALF_DOWN-+   
                                              +-ROUND_HALF_EVEN-+   
                                              +-ROUND_HALF_UP---+   
                                              +-ROUND_UP--------+   
                                              +-string-constant-+   
                                              '-host-variable---'   

Description

ROUND_CEILING
Round towards positive 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 1 (round up).
ROUND_DOWN
Round towards 0 (truncation). The discarded digits are ignored.
ROUND_FLOOR
Round towards negative infinity. If all of the discarded digits are zero or if the sign is positive, the result is unchanged other than the removal of discarded digits. Otherwise, the sign is negative and the result coefficient is incremented by 1 (round down).
ROUND_HALF_DOWN
Round to nearest value; if values are equidistant, rounds down. If the discarded digits represent greater than half (0.5) of the value of a number in the next left position, the result coefficient is incremented by 1 (round up). Otherwise, the discarded digits are ignored. This rounding mode is not recommended when creating a portable application because it is not supported by the IEEE draft standard for floating-point arithmetic.
ROUND_HALF_EVEN
Round to nearest value; if values are equidistant, round so that the final digit is even. If the discarded digits represent greater than half (0.5) of the value of a number in the next left position, the result coefficient is incremented by 1 (round up). If the discarded digits represent less than half of the value, the result coefficient is not adjusted (that is, the discarded digits are ignored). Otherwise, the result coefficient is unaltered if its rightmost digit is even, or is incremented by 1 (round up) if its rightmost digit is odd (to make an even digit).
ROUND_HALF_UP
Round to nearest value; if values are equidistant, round up. If the discarded digits represent greater than or equal to half (0.5) of the value of a number in the next left position, the result coefficient is incremented by 1 (round up). Otherwise the discarded digits are ignored.
ROUND_UP
Round away from 0. 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 1 (round up). This rounding mode is not recommended when creating a portable application because it is not supported by the IEEE draft standard for floating-point arithmetic.
string-constant
Specifies a string constant that contains a specification of the rounding mode. The string-constant must have the following characteristics:
  • Must be a string constant. The actual length of the contents of the string constant, after trailing blanks have been removed, must not exceed 19 characters.
  • Must not be the null value.
  • Must not contain lower case letters or characters that cannot be specified in an ordinary identifier.
  • Must specify one of the seven rounding mode keywords as a string constant.
host-variable
Specifies a variable that contains a specification of the rounding mode. The variable must have the following characteristics:
  • Must have a length, after trailing blanks have been removed, that does not exceed 19 bytes.
  • Must not be followed by an indicator variable.
  • Must not be a CLOB or DBCLOB.
  • Must include a rounding mode that is left justified and conforms to the rules for forming an ordinary identifier.
  • Must not contain lower case letters or characters that cannot be specified in an ordinary identifier.
  • Must be padded on the right with blanks if the variable is a fixed length string.
  • Must contain one of the seven rounding mode keywords.

Examples

Example: The following statement sets the CURRENT DECFLOAT ROUNDING MODE to ROUND_CEILING, using a string constant and a keyword.
   SET CURRENT DECFLOAT ROUNDING MODE = ROUND_CEILING;