Skip to main content
Scalar function
Returns NULL when value or an explicitly provided decimal_places is NULL.

Syntax

Scalar

Arguments

Returns

  • Type: FLOAT for FLOAT input; DOUBLE for other nondecimal input; DECIMAL with adjusted precision and scale for decimal input
  • Possible values: The number rounded to decimal_places digits.
  • NULL behavior: Returns NULL when value or an explicitly provided decimal_places is NULL.

Properties

  • Approximation bound: No fixed bound is declared for floating-point rounding.

Usage notes

  • The optional decimal_places argument defaults to zero and need not be a constant.
  • For a decimal value and literal nonnegative decimal_places, the output scale is the smaller of the input scale and decimal_places. Negative positions use output scale zero.
  • For an integer-scale decimal rounded at a negative position, precision can increase by one, up to the decimal type maximum.
  • For a decimal value and nonliteral decimal_places, the result retains its input scale and may gain one precision digit to accommodate a carry.
  • Floating-point inputs multiply by 10^decimal_places, round and divide back, so binary representation and intermediate overflow/underflow can affect extreme cases.
  • INTEGER and INT mean the same type; STRING means VARCHAR text. NULL can be used with a supported type. Cast NULL explicitly when its type would otherwise be unclear.

Examples

Normal values and NULL behavior

Decimal places and trailing digits

Limitations

  • Decimal precision overflow and unsupported out-of-range decimal_places can raise an execution error.
Last modified on October 15, 2026