Expand description
The mathematical library.
Provides basic mathematical functions and the interface to the
integer/float subtypes of number. Functions annotated
“integer/float” give integer results for integer arguments and float
results otherwise.
Constants§
- huge
- A value larger than any other numerical value: the float infinity,
HUGE_VAL. - maxinteger
- An integer with the maximum value for an integer: 9223372036854775807 (2⁶³ − 1).
- mininteger
- An integer with the minimum value for an integer: −9223372036854775808 (−2⁶³).
- pi
- The value of π.
Functions§
- abs
- Returns the absolute value of a number (integer/float).
- acos
- Returns the arc cosine of a number, in radians.
- asin
- Returns the arc sine of a number, in radians.
- atan
- Returns the arc tangent of
y/x, in radians. - ceil
- Rounds a number up to the nearest integer.
- clamp
extended - Restricts a number to a range.
Extended library — feature
extended(fromextended.lua). From Rustf64::clamp. - cos
- Returns the cosine of a number given in radians.
- deg
- Converts an angle from radians to degrees.
- exp
- Returns e raised to a power.
- floor
- Rounds a number down to the nearest integer.
- fmod
- Returns the remainder of a division, rounding the quotient towards zero (integer/float).
- frexp
- Splits a number into a normalized fraction and an exponent. Re-added in Lua 5.5 (it had been removed in 5.3).
- ldexp
- Builds a float from a mantissa and an exponent. Re-added in Lua 5.5 (it had been removed in 5.3).
- log
- Returns the logarithm of a number in a given base.
- max
- Returns the largest of its arguments.
- min
- Returns the smallest of its arguments.
- modf
- Splits a number into its integral and fractional parts.
- rad
- Converts an angle from degrees to radians.
- random
- Returns a pseudo-random number.
- randomseed
- Initialises the pseudo-random number generator.
- round
extended - Rounds a number to the nearest integer, halves away from zero.
Extended library — feature
extended(fromextended.lua). - sign
extended - Returns the sign of a number: 1, −1 or 0. NaN is returned
unchanged.
Extended library — feature
extended(fromextended.lua). From Rustf64::signum. - sin
- Returns the sine of a number given in radians.
- sqrt
- Returns the square root of a number.
- tan
- Returns the tangent of a number given in radians.
- tointeger
- Converts a value to an integer, if possible.
- type
- Reveals the subtype of a number.
- ult
- Compares two integers as unsigned values.