Game Development Reference
In-Depth Information
math.ldexp (m, e)
This returns a number generated from the combination of the mantissa
m
and the exponent
e
. The
formula used is
number = m * 2^e
Here's the function in use:
print(math.ldexp(0.5, 8)) -- 128
x
.
x
.
This returns the maximum value among the passed values.
print(math.max(2,5,3,8,3,4,5)) -- 8
math.min (x, …)
This returns the minimum value among the passed values.
print(math.min(2,5,3,8,3,4,5)) -- 2
math.modf (x)
This returns the integer and the fractional part of the number passed. So, if we passed it
x.y
, it would
return
x
and
y
.
print(math.modf(3.75)) -- 3
0.75
math.pi
This returns the math constant of pi.
print(math.pi) -- 3.1415926535898