Module:CommonFunctions: Difference between revisions

no edit summary
No edit summary
No edit summary
Tag: Reverted
Line 137: Line 137:
end
end


function math.round(num, decimals)
math.round = function(num)  
    decimals = math.pow(10, decimals or 0)
return math.floor(num+.5)
    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