This is an old revision of the document!
There are four rounding modes:
trunc
– zeroes the fractional part of the numberfloor
– rounds the number downceil
– round the number upround
– rounds the number to the closest integerRounding table:
x | round(x) | floor(x) | ceil(x) | trunc(x) |
---|---|---|---|---|
2.3 | 2 | 2 | 3 | 2 |
3.8 | 4 | 3 | 4 | 3 |
5.5 | 6 | 5 | 6 | 5 |
-2.3 | -2 | -3 | -2 | -2 |
-3.8 | -4 | -4 | -3 | -3 |
-5.5 | -5 | -6 | -5 | -5 |
Every rounding mode is available as two functions. The ones with the “i” in the name return an integer, while the ones without the “i” return a fixed.