1. Rounding numbers
When performing calculations, you want your numbers to be as accurate as possible. However, reading numbers with eight decimal places is tiresome, so when you come to report numbers, it is often useful to round them first.
2. Rounding
The ROUND() function, as you might expect, rounds numbers. If you give it one argument, it will round the input to the nearest whole number, as shown by the first command here.
You can also specify the number of decimal places to round the number to. In the next row, you can see that specifying two decimal places rounds the number to the nearest hundredth. The final row shows that specifying negative two decimal places rounds the number to the nearest hundred.
3. Ceiling and floor (1)
ROUND() always rounds toward the nearest whole number, but sometimes you may wish to always round upwards or always round downwards. This is accomplished through the CEILING() and FLOOR() functions.
CEILING() rounds to the nearest whole number towards infinity, and FLOOR() rounds towards negative infinity.
4. Ceiling and floor (2)
CEILING() and FLOOR() also provide ways to round to fractions of numbers, but the syntax is different to ROUND(). In order to round up or down to the nearest hundredth, rather than specifying two decimal places, you would pass one hundredth directly.
5. Summary
You've just seen three functions for rounding numbers. ROUND() will round up or down to the nearest value; CEILING() always rounds up towards infinity, and FLOOR() always rounds round toward negative infinity.
6. Let's get rounding!
Alright! Let's try some rounding!