FirebirdSQL logo

ROUND()

Result type

single argument: integer type, DOUBLE PRECISION or DECFLOAT;
two arguments: numerical, matching first argument

Syntax
ROUND (number [, scale])
Table 1. ROUND Function Parameters
Parameter Description

number

An expression of a numeric type

scale

An integer specifying the number of decimal places toward which rounding is to be performed, e.g.:

  •  2 for rounding to the nearest multiple of 0.01

  •  1 for rounding to the nearest multiple of 0.1

  •  0 for rounding to the nearest whole number

  • -1 for rounding to the nearest multiple of 10

  • -2 for rounding to the nearest multiple of 100

Rounds a number to the nearest integer.If the fractional part is exactly 0.5, rounding is upward for positive numbers and downward for negative numbers.With the optional scale argument, the number can be rounded to powers-of-ten multiples (tens, hundreds, tenths, hundredths, etc.).

Important

If you are used to the behaviour of the external function ROUND, please notice that the internal function always rounds halves away from zero, i.e. downward for negative numbers.

ROUND Examples

If the scale argument is present, the result usually has the same scale as the first argument:

ROUND(123.654, 1) -- returns 123.700 (not 123.7)
ROUND(8341.7, -3) -- returns 8000.0 (not 8000)
ROUND(45.1212, 0) -- returns 45.0000 (not 45)

Otherwise, the result scale is 0:

ROUND(45.1212) -- returns 45