QUANTIZE()
Returns a value that is equal in value — except for rounding — to the first argument, but with the same exponent as the second argument
DECFLOAT
QUANTIZE (decfloat_value, exp_value)
Parameter | Description |
---|---|
decfloat_value |
Value or expression to quantize;needs to be of type |
exp_value |
Value or expression to use for its exponent;needs to be of type |
QUANTIZE
returns a DECFLOAT
value that is equal in value and sign (except for rounding) to decfloat_value, and that has an exponent equal to the exponent of exp_value.The type of the return value is DECFLOAT(16)
if both arguments are DECFLOAT(16)
, otherwise the result type is DECFLOAT(34)
.
Note
|
The target exponent is the exponent used in the |
If the exponent of decfloat_value is greater than the one of exp_value, the coefficient of decfloat_value is multiplied by a power of ten, and its exponent decreased.If the exponent is smaller, then its coefficient is rounded using the current decfloat rounding mode, and its exponent is increased.
When it is not possible to achieve the target exponent because the coefficient would exceed the target precision (16 or 34 decimal digits), either a “Decfloat float invalid operation” error is raised or NaN
is returned (depending on the current decfloat traps configuration).
There are almost no restrictions on the exp_value.However, in almost all usages, NaN
/sNaN
/Infinity
will produce an exception (unless allowed by the current decfloat traps configuration), NULL
will make the function return NULL
, and so on.