round 7

Round a number to a specific quantity to decimal points


Return value

Return TypeDescription
floatRounded value

Parameters

ParameterTypeDescription
1floatNumber to round
2integerHow 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"

Back to Scripting API