Function round()

← Back to Module math



Module math → round()

Description

Round x to specified precision

round(x, precision = 0)


Parameters


Return Value


Usage Example

round(23.6)        ' Returns 24
round(23.728, 2)   ' Returns 23.73
 
' The difference between floor, ceil, round, and int
 
' x       floor(x)   ceil(x)   round(x, 0)   int(x)
' -----   --------   -------   -----------   ------
'  2.3     2          3         2             2
'  3.8     3          4         4             3
'  5.5     5          6         6             5
' -2.3    -3         -2        -2            -2
' -3.8    -4         -3        -4            -3
' -5.5    -6         -5        -6            -5