The Mathematical Library holds Lua built-in functions that relate to math. These math functions include those relating to trigonometry (like
cos), exponents (
^), logs (
logN), rounding (
ceil), max, min, and pi.
Lua’s Mathematical Library contains various math functionalities, but here are a few most commonly used functions:
math.max(x, ..): Returns the max value from arguments.
math.min(x, ..): Returns the min value from arguments.
math.pow(x, y): Returns x to the y power (x^y).
math.random(a, ...): Returns a random integer between 0 and 1 when no arguments are given, a random integer from 1 to a when one argument is given, or a random integer between a and b when two arguments are given.
math.sqrt(x): Returns square root of x (√x).
A full list of math functions can be found on the Lua documentation page.
- Anonymous contributorAnonymous contributor3 total contributions
- Anonymous contributor