Rounds a number away from zero.
Notes:
math.sign
is not available in all Lua versions. See this Stack Overflow question for more details.advtrains.abs_ceil(i)
i
(number): a number.The specified argument rounded away from zero.
advtrains.abs_ceil(3) -- 3 advtrains.abs_ceil(3.1) -- 4 advtrains.abs_ceil(3.5) -- 4 advtrains.abs_ceil(3.9) -- 4 advtrains.abs_ceil(-3) -- -3 advtrains.abs_ceil(-3.1) -- -4 advtrains.abs_ceil(-0.00001) -- -1 advtrains.abs_ceil( 0.00001) -- 1
advtrains/helpers.lua, lines 186 to 188:
function advtrains.abs_ceil(i) return math.ceil(math.abs(i))*math.sign(i) end