Math

February 18, 2015 ยท View on GitHub

math

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.

extensions

The math library has been extended with some additional functions.

math.round( x )

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