|
|
@ -18,7 +18,7 @@ end |
|
|
|
|
|
|
|
|
|
|
|
-- rounds a number to the nearest decimal places |
|
|
|
-- rounds a number to the nearest decimal places |
|
|
|
-- e.g. round(1.523, 100) -- 1.52 |
|
|
|
-- e.g. round(1.523, 100) -- 1.52 |
|
|
|
function round(val, decimal) |
|
|
|
function M.round(val, decimal) |
|
|
|
if (decimal) then |
|
|
|
if (decimal) then |
|
|
|
return math.floor( (val * 10^decimal) + 0.5) / (10^decimal) |
|
|
|
return math.floor( (val * 10^decimal) + 0.5) / (10^decimal) |
|
|
|
else |
|
|
|
else |
|
|
|