Game Development Reference
In-Depth Information
math.deg (x)
This function converts a value from degree to radians.
print(math.deg(math.pi)) -- 180
math.exp (x)
This returns e , the base of natural logarithms raised to a given power.
print (math.exp(2)) -- 7.3890560989307
math.floor (x)
This returns the lower integer value from the passed value of x .
print (math.floor(0.1)) -- 0
print (math.floor(0.5)) -- 0
print (math.floor(0.9)) -- 0
math.fmod (x)
This returns the remainder of the division of the arguments that rounds the quotient toward zero,
according to the following equation:
remainder = numerator - quotient * denominator
The function itself is used like this:
print(math.fmod(7.5,3)) -- 1.5
math.frexp (x)
This function splits the value into a normalized fraction and an exponent. The results are two
numbers. The number x can be represented as follows:
fraction * 2^exponent
Here are some examples of the function in code:
print(math.frexp(2)) -- 0.5 2
print(math.frexp(3)) -- 0.75 1
print(math.frexp(1)) -- 0.5
1
math.huge
This is a constant than a function; it returns inf , which is a very large number.
print(math.inf)
 
Search WWH ::




Custom Search