Forum
CS2D Scripts Rounding Off With LuaRounding Off With Lua
5 replies 1
math.floor / math.ceil
I don't know if there's a math.round or something like that but it wouldn't be hard to implement it with these two functions. Maybe casting to integer somehow works as well.
Admin/mod comment
Yes, you did. I removed the second one. /DC1
2
3
2
3
function round(num, idp) 	return tonumber(string.format("%." .. (idp or 0) .. "f", num)) end
So you would use it like...
1
round((75.65*8), 2)
Also check out this link, would most likely help you. Simple Rounding
1
2
3
2
3
function math.round(n) 	return math.floor(n+.5) end
Good luck
1
2
3
2
3
function roundup(x) 	return math.floor(x + 0.5) end
Edit:
Ugh, I'm way too late
1