Module:CommonFunctions: Difference between revisions
From Elwiki
No edit summary |
No edit summary |
||
Line 135: | Line 135: | ||
function table.not_empty(tbl) | function table.not_empty(tbl) | ||
return not next(tbl) | return not next(tbl) | ||
end | |||
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 |