6.7 – Mathematical Functions

This library provides basic mathematical functions. It provides all its functions and constants inside the table math. Functions with the annotation "integer/float" give integer results for integer arguments and float results for float (or mixed) arguments. Rounding functions (math.ceil, math.floor, and math.modf) return an integer when the result fits in the range of an integer, or a float otherwise.

math.log()
  • References/Lua/Lua/Standard Libraries/Mathematical Functions

math.log (x [, base]) Returns the logarithm of x in the given base. The default for base is e (so that the function returns the natural logarithm

2025-01-10 15:47:30
math.tointeger()
  • References/Lua/Lua/Standard Libraries/Mathematical Functions

math.tointeger (x) If the value x is convertible to an integer, returns that integer. Otherwise, returns nil.

2025-01-10 15:47:30
math.sqrt()
  • References/Lua/Lua/Standard Libraries/Mathematical Functions

math.sqrt (x) Returns the square root of x. (You can also use the expression x^0.5 to compute this value.)

2025-01-10 15:47:30
math.acos()
  • References/Lua/Lua/Standard Libraries/Mathematical Functions

math.acos (x) Returns the arc cosine of x (in radians).

2025-01-10 15:47:30
math.huge
  • References/Lua/Lua/Standard Libraries/Mathematical Functions

math.huge The float value HUGE_VAL, a value larger than any other numeric value.

2025-01-10 15:47:30
math.ceil()
  • References/Lua/Lua/Standard Libraries/Mathematical Functions

math.ceil (x) Returns the smallest integral value larger than or equal to x.

2025-01-10 15:47:30
math.cos()
  • References/Lua/Lua/Standard Libraries/Mathematical Functions

math.cos (x) Returns the cosine of x (assumed to be in radians).

2025-01-10 15:47:30
math.atan()
  • References/Lua/Lua/Standard Libraries/Mathematical Functions

math.atan (y [, x]) Returns the arc tangent of y/x (in radians), but uses the signs of both parameters to find the quadrant of the result. (It also handles correctly

2025-01-10 15:47:30
math.modf()
  • References/Lua/Lua/Standard Libraries/Mathematical Functions

math.modf (x) Returns the integral part of x and the fractional part of x. Its second result is always a float.

2025-01-10 15:47:30
math.exp()
  • References/Lua/Lua/Standard Libraries/Mathematical Functions

math.exp (x) Returns the value ex (where e is the base of natural logarithms).

2025-01-10 15:47:30