Skip to main content
Version: latest - a1.73.x βš–οΈ

math

This library provides basic mathematical functions. It provides all its functions and constants inside the table math.

πŸ§‘β€πŸ’»API Source
This page is auto-generated! The Functions, Properties and Events described here are defined in our GitHub's API Repository! Feel free to commit suggestions and changes to the source .json API files!

πŸŽ’ Examples​

TODO Examples

πŸ—Ό Static Properties​

ValueName
3.141592653589793math.pi
2^1024math.huge

πŸ—Ώ Static Functions​

ReturnsNameDescription
Return the integer no greater than the given value (even for negatives)
Return the tangent value for a given value in radians.
Return the minimum value from a variable length list of arguments
Returns the remainder of the division of base by modulator that rounds the quotient towards zero
Returns e (the base of natural logarithms) raised to the power exponent
Generates pseudo-random numbers uniformly distributed
Convert from degrees to radians
Return the sine value for a given value in radians.
Return the cosine value for a given value in radians.
Return the inverse sine in radians of the given value.
Sets a seed for the pseudo-random generator: Equal seeds produce equal sequences of numbers
Return the integer no less than the given value (even for negatives)
Return the maximum value from a variable length list of arguments
Return the inverse tangent in radians. We can do this by supplying y/x ourselves or we can pass y and x to math.atan to do this for us
Return the inverse cosine in radians of the given value.
Return the absolute, or non-negative value, of a given value
Returns the inverse of this. math.exp(1) returns e
, Return the integral and fractional parts of the given number
Convert from radians to degrees
Return the square root of a given number. Only non-negative arguments are allowed

ceil

Return the integer no greater than the given value (even for negatives)

β€” Returns .

local ret = math.ceil(number)
TypeParameterDefaultDescription
number Required parameter The number to be rounded up.

tan

Return the tangent value for a given value in radians.

β€” Returns .

local ret = math.tan(value)
TypeParameterDefaultDescription
value Required parameter Angle in radians

min

Return the minimum value from a variable length list of arguments

β€” Returns .

local ret = math.min(numbers...)
TypeParameterDefaultDescription
of numbers... Required parameter Numbers to get the smallest from.

fmod

Returns the remainder of the division of base by modulator that rounds the quotient towards zero

β€” Returns .

local ret = math.fmod(base, modulator)
TypeParameterDefaultDescription
base Required parameter The base value.
modulator Required parameter The modulator.

exp

Returns e (the base of natural logarithms) raised to the power exponent

β€” Returns .

local ret = math.exp(exponent)
TypeParameterDefaultDescription
exponent Required parameter The exponent for the function.

random

Generates pseudo-random numbers uniformly distributed

β€” Returns .

local ret = math.random(m, n)
TypeParameterDefaultDescription
m Required parameter If m is the only parameter: upper limit. If n is also provided: lower limit. If provided, this must be an integer.
n Required parameter Upper limit. If provided, this must be an integer.

rad

Convert from degrees to radians

β€” Returns .

local ret = math.rad(degrees)
TypeParameterDefaultDescription
degrees Required parameter The angle measured in degrees.

sin

Return the sine value for a given value in radians.

β€” Returns .

local ret = math.sin(number)
TypeParameterDefaultDescription
number Required parameter Angle in radians

cos

Return the cosine value for a given value in radians.

β€” Returns .

local ret = math.cos(number)
TypeParameterDefaultDescription
number Required parameter Angle in radians

asin

Return the inverse sine in radians of the given value.

β€” Returns .

local ret = math.asin(normal)
TypeParameterDefaultDescription
normal Required parameter Sine value in the range of -1 to 1.

randomseed

Sets a seed for the pseudo-random generator: Equal seeds produce equal sequences of numbers

math.randomseed(seed)
TypeParameterDefaultDescription
seed Required parameter The new seed

floor

Return the integer no less than the given value (even for negatives)

β€” Returns .

local ret = math.floor(number)
TypeParameterDefaultDescription
number Required parameter The number to be rounded down.

max

Return the maximum value from a variable length list of arguments

β€” Returns .

local ret = math.max(numbers...)
TypeParameterDefaultDescription
of numbers... Required parameter Numbers to get the largest from

atan

Return the inverse tangent in radians. We can do this by supplying y/x ourselves or we can pass y and x to math.atan to do this for us

β€” Returns .

local ret = math.atan(normal)
TypeParameterDefaultDescription
normal Required parameter Tangent value.

acos

Return the inverse cosine in radians of the given value.

β€” Returns .

local ret = math.acos(cos)
TypeParameterDefaultDescription
cos Required parameter Cosine value in range of -1 to 1.

abs

Return the absolute, or non-negative value, of a given value

β€” Returns .

local ret = math.abs(x)
TypeParameterDefaultDescription
x Required parameter The number to get the absolute value of.

log

Returns the inverse of this. math.exp(1) returns e

β€” Returns .

local ret = math.log(x, base)
TypeParameterDefaultDescription
x Required parameter The value to get the base from exponent from.
base Required parameter The logarithmic base.

modf

Return the integral and fractional parts of the given number

β€” Returns , (, ).

local ret_01, ret_02 = math.modf(base)
TypeParameterDefaultDescription
base Required parameter The base value.

deg

Convert from radians to degrees

β€” Returns .

local ret = math.deg(radians)
TypeParameterDefaultDescription
radians Required parameter Value to be converted to degrees.

sqrt

Return the square root of a given number. Only non-negative arguments are allowed

β€” Returns .

local ret = math.sqrt(value)
TypeParameterDefaultDescription
value Required parameter Value to get the square root of.