The math
library is a standard Lua library. It is a global library and does not need to be imported.
print(math.abs(-123)); -- 123
Refer to the official Lua documentation for more details.
The math
library has been extended with some additional functions.
Rounds the value x
to the nearest integer (rounds 0.5 up).
print(math.round(1.25)); -- 1
print(math.round(1.5)); -- 2
print(math.round(1.75)); -- 2