DB2 Version 10.1 for Linux, UNIX, and Windows

QUANTIZE scalar function

The QUANTIZE function returns a decimal floating-point value that is equal in value (except for any rounding) and sign to numeric-expression and that has an exponent equal to the exponent of exp-expression. The number of digits (16 or 34) is the same as the number of digits in numeric-expression.

Read syntax diagramSkip visual syntax diagram
>>-QUANTIZE--(--numeric-expression--,--exp-expression--)-------><

The schema is SYSIBM.

numeric-expression
An expression that returns a value of any built-in numeric data type. If the argument is not a decimal floating-point value, it is converted to DECFLOAT(34) for processing.
exp-expression
An expression that returns a value of any built-in numeric data type. If the argument is not a decimal floating-point value, it is converted to DECFLOAT(34) for processing. The exp-expression is used as an example pattern for rescaling numeric-expression. The sign and coefficient of exp-expression are ignored.

The coefficient of the result is derived from that of numeric-expression. It is rounded, if necessary (if the exponent is being increased), multiplied by a power of ten (if the exponent is being decreased), or remains unchanged (if the exponent is already equal to that of exp-expression).

The CURRENT DECFLOAT ROUNDING MODE special register determines the rounding mode.

Unlike other arithmetic operations on the decimal floating-point data type, if the length of the coefficient after the quantize operation is greater than the precision specified by exp-expression, the result is NaN and a warning is returned (SQLSTATE 0168D). This ensures that, unless there is a warning condition, the exponent of the result of QUANTIZE is always equal to that of exp-expression.

The result of the function is a DECFLOAT(16) value if both arguments are DECFLOAT(16). Otherwise, the result of the function is a DECFLOAT(34) value. The result can be null; if any argument is null, the result is the null value.

Examples