#
math
This is an expansion to the existing Lua Math library.
Expansion Library
This is an expansion to builtins provided by Lua itself, see more about them on the official Lua/LuaJIT wikis.
#
Functions
math.abs(v: number): number
- Absolute value of v.
math.acos(v: number): number
- Arc cosine of v. (Inverse operation of math.cos (v)).
math.asin(v: number): number
- Arc sine of v. (Inverse operation of math.sin(v)).
math.atan(v: number): number
- Arc tangent of v. (Inverse operation of math.tan (v)).
math.atan2(v1: number, v2: number): number
- Arc tangent of v1/v2.
math.ceil(v: number): number
- Smallest integer >= v
math.cos(v: number): number
- Cosine of v radians.
math.cosh(v: number): number
- Hyperbolic cosine of v radians.
math.deg(v: number): number
- Convert v from radians to degrees. Note that math.rad is the inverse operation.
math.exp(v: number): number
- Compute e to the power v. Note that math.log is the inverse operation.
math.floor(v: number): number
- Largest integer <= v
math.fmod(v1: number, v2: number): number
- The modulus (remainder) of doing: v1 / v2
math.frexp(v: number): number, number
- The frexp function breaks down the floating-point value (v) into a mantissa (m) and an exponent (n), such that the absolute value of m is greater than or equal to 0.5 and less than 1.0, and v = m * 2^n.
math.huge: number
- The value HUGE_VAL, a value larger than or equal to any other numerical value.
- Note that this is a number, not a function.
math.ldexp(m: number, n: number): number
- The ldexp function returns the value of m * 2^n.
math.log(v: number): number
- Natural log of v (that is, to the base e).
math.log10(v: number): number
- Log to the base 10 of v.
math.max(...: number): number
- The highest of one or more numbers.
math.min(...: number): number
- The lowest of one or more numbers.
math.modf(v: number): number, number
- Returns two numbers, the integral part of v and the fractional part of v
math.pi: number
- A variable representing the value of pi (not a function).
math.pow(v1: number, v2: number): number
- v1 raised to the power v2.
math.rad(v: number): number
- Convert v from degrees to radians.
math.random(n?: number, u?: number): number
- With no arguments, returns a random number in the range [0, 1]. That is, zero up to but excluding 1.
- With 1 argument, returns an integer in the range [1, n]. That is from 1 up to and including n.
- With 2 arguments, returns an integer in the range [n, u]. That is from n up to and including u.
- Use
math.randomseed(n: number)
to seed the generator.
math.randomseed(n: number)
- Seeds the random number generator with an integer.
- Re-seed with the same number to regenerate the same sequences by calling math.random.
- Seeding with os.time () is a common technique to make random numbers different each time.
math.sin(v: number): number
- Sine of v radians.
math.sinh(v: number): number
- Hyperbolic sine of v radians.
math.sqrt(v: number): number
- Square root of v.
math.tan(v: number): number
- Tangent of v radians.
math.tanh(v: number): number
- Hyperbolic tangent of v radians.