Module:CommonFunctions: Difference between revisions
From Elwiki
No edit summary Tag: Reverted |
No edit summary Tag: Manual revert |
||
Line 137: | Line 137: | ||
end | end | ||
math.round = | function math.round(num, decimals) | ||
decimals = math.pow(10, decimals or 0) | |||
num = num * decimals | |||
if num >= 0 then num = math.floor(num + 0.5) else num = math.ceil(num - 0.5) end | |||
return num / decimals | |||
end | end |