--四舍五入
function rounding(value)
local positive = 1
if value < 0 then
positive = -1
end
value = math.abs(value)
local int, decimal = math.modf(value)
decimal = tostring(decimal * 10)
decimal = string.sub(decimal, 1, 1)
if tonumber(decimal) > 5 then
int = int + 1
end
return int * positive
end
转载于:https://www.cnblogs.com/Joke-crazy/p/9188162.html