Syntax
Parameters
Parameter | Description | Supported input types |
---|---|---|
<value> | The value to be rounded | |
<decimal> | Optional. An INTEGER constant that defines the decimal range of the returned value. By default, ROUND returns whole numbers. | INTEGER |
Return Types
DOUBLE PRECISION
Rounding behavior
When rounding values that are exactly halfway between two possible results (for example, 1.5 or 2.5 when rounding to the nearest integer),ROUND
uses different strategies depending on the data type:
- DOUBLE PRECISION: Uses banker’s rounding (also called round half to even). Ties are rounded to the nearest even number. For example, both
1.5
and2.5
round to2
(the nearest even number). - NUMERIC: Uses standard rounding (round half up). Ties are always rounded up. For example,
1.5
rounds to2
and2.5
rounds to3
.
Example
The following example returns the rounded value of 5.4. Since there is no specification of the decimal range, the functions returns a whole number: The following example rounds the value 5.6930 to 1 decimal place: The following examples demonstrate the tie-breaking behavior for values exactly halfway between two results: Notice how both1.5
and 2.5
round to 2
(the nearest even number). This is banker’s rounding behavior for DOUBLE PRECISION
types.
With NUMERIC
types, ties round up instead:
The same tie-breaking behavior applies when rounding to a specific number of decimal places:
Both 1.15
and 1.25
round to 1.2
when rounding to 1 decimal place, demonstrating banker’s rounding.
With NUMERIC
types at a specific decimal precision: