Mathematical Library
Anonymous contributor
Anonymous contributor3 total contributions
Anonymous contributor
Published Aug 15, 2023
Contribute to Docs
The Mathematical Library holds Lua built-in functions that relate to math. These math functions include those relating to trigonometry (like sin
and cos
), exponents (exp
or ^
), logs (logN
), rounding (floor
, ceil
), max, min, and pi.
Math Functions
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.
All contributors
- Anonymous contributorAnonymous contributor3 total contributions
- Anonymous contributor
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.