The ROUND function rounds a number to the nearest integer or the specified number of digits.
ROUND(
number,
num_digits
)
- number: Number to round.
- num_digits: Number of digits to round number to.
The ROUND function returns a real number.
If num_digits is greater than zero, the number is rounded to that number of decimal places. If it is zero, it is rounded to the nearest integer. Finally, if it is negative, it is rounded to the left of the decimal point (to the nearest multiple of 10-num_digits, see example below).
This example rounds a positive and a negative number to a variable number of digits:
In this other example, multiple numbers are rounded to zero digits. Notice how the result is the closest integer:
The behavior of the different rounding functions is summarized below:
- ROUNDDOWN: Rounds a number towards zero and the number of decimal places can be specified.
- ROUNDUP: Rounds a number away from zero and the number of decimal places can be specified.
- ROUND: Rounds a number towards the nearest rounding value and the number of decimal places can be specified.
- INT: Rounds a number to the nearest equal or lower integer.
- TRUNC: Rounds a number towards its integer part and the number of decimal places can be specified.
Examples: