round 7
Round a number to a specific quantity to decimal points
Return value
Return Type | Description |
---|---|
float | Rounded value |
Parameters
Parameter | Type | Description |
---|---|---|
1 | float | Number to round |
2 | integer | How many decimal points are allowed |
Examples
local num1 = 10.123456
local num2 = 3.141592
num1 = round(num1, 0) -- remove all decimal points
num2 = round(num2, 2) -- round up to the first 2 decimal points
print(num1) -- shows "10"
print(num2) -- shows "3.14"