public final class MathLib extends Object
math. Functions with the annotation "integer/float" give integer
results for integer arguments and float results for float (or mixed) arguments. Rounding
functions (math.ceil, math.floor,
and math.modf) return an integer when the result fits
in the range of an integer, or a float otherwise.| Modifier and Type | Field and Description |
|---|---|
static Double |
HUGE
math.huge |
static Long |
MAXINTEGER
An integer with the maximum value for an integer.
|
static Long |
MININTEGER
An integer with the minimum value for an integer.
|
static Double |
PI
math.pi |
| Modifier and Type | Method and Description |
|---|---|
static org.classdump.luna.runtime.LuaFunction |
abs()
Returns the function
math.abs. |
static org.classdump.luna.runtime.LuaFunction |
acos()
Returns the function
math.acos. |
static org.classdump.luna.runtime.LuaFunction |
asin()
Returns the function
math.asin. |
static org.classdump.luna.runtime.LuaFunction |
atan()
Returns the function
math.atan. |
static org.classdump.luna.runtime.LuaFunction |
ceil()
Returns the function
math.ceil. |
static org.classdump.luna.runtime.LuaFunction |
cos()
Returns the function
math.cos. |
static org.classdump.luna.runtime.LuaFunction |
deg()
Returns the function
math.deg. |
static org.classdump.luna.runtime.LuaFunction |
exp()
Returns the function
math.exp. |
static org.classdump.luna.runtime.LuaFunction |
floor()
Returns the function
math.floor. |
static org.classdump.luna.runtime.LuaFunction |
fmod()
Returns the function
math.fmod. |
static void |
installInto(org.classdump.luna.StateContext context,
org.classdump.luna.Table env)
Installs the math library to the global environment
env in the state
context context, with a new random number generator of class Random. |
static void |
installInto(org.classdump.luna.StateContext context,
org.classdump.luna.Table env,
Random random)
Installs the math library to the global environment
env in the state
context context, with the random number generator random. |
static org.classdump.luna.runtime.LuaFunction |
log()
Returns the function
math.log. |
static org.classdump.luna.runtime.LuaFunction |
max()
Returns the function
math.max. |
static org.classdump.luna.runtime.LuaFunction |
min()
Returns the function
math.min. |
static org.classdump.luna.runtime.LuaFunction |
modf()
Returns the function
math.modf. |
static org.classdump.luna.runtime.LuaFunction |
rad()
Returns the function
math.rad. |
static org.classdump.luna.runtime.LuaFunction |
random(Random random)
Returns a function
math.random that uses the argument random
as a random number generator. |
static org.classdump.luna.runtime.LuaFunction |
randomseed(Random random)
Returns a function
math.randomseed that sets the seed of the random
generator random. |
static org.classdump.luna.runtime.LuaFunction |
sin()
Returns the function
math.sin. |
static org.classdump.luna.runtime.LuaFunction |
sqrt()
Returns the function
math.sqrt. |
static org.classdump.luna.runtime.LuaFunction |
tan()
Returns the function
math.tan. |
static org.classdump.luna.runtime.LuaFunction |
tointeger()
Returns the function
math.tointeger. |
static org.classdump.luna.runtime.LuaFunction |
type()
Returns the function
math.type. |
static org.classdump.luna.runtime.LuaFunction |
ult()
Returns the function
math.ult. |
public static final Double HUGE
math.huge
The value HUGE_VAL, a value larger than or equal to any other numerical
value.
public static final Long MAXINTEGER
public static final Long MININTEGER
public static final Double PI
math.pi
The value of π.
public static org.classdump.luna.runtime.LuaFunction abs()
math.abs.
The following is the corresponding entry from the Lua Reference Manual:
math.abs (x)Returns the absolute value of
x. (integer/float)
math.abs functionmath.abspublic static org.classdump.luna.runtime.LuaFunction acos()
math.acos.
The following is the corresponding entry from the Lua Reference Manual:
math.acos (x)Returns the arc cosine of
x(in radians).
math.acos functionmath.acospublic static org.classdump.luna.runtime.LuaFunction asin()
math.asin.
The following is the corresponding entry from the Lua Reference Manual:
math.asin (x)Returns the arc sine of
x(in radians).
math.asin functionmath.asinpublic static org.classdump.luna.runtime.LuaFunction atan()
math.atan.
The following is the corresponding entry from the Lua Reference Manual:
math.atan (x)Returns the arc tangent of
y/x(in radians), but uses the signs of both parameters to find the quadrant of the result. (It also handles correctly the case ofxbeing zero.)The default value for
xis 1, so that the callmath.atan(y)returns the arc tangent ofy.
math.atan functionmath.atanpublic static org.classdump.luna.runtime.LuaFunction ceil()
math.ceil.
The following is the corresponding entry from the Lua Reference Manual:
math.ceil (x)Returns the smallest integer larger than or equal to
x.
math.ceil functionmath.ceilpublic static org.classdump.luna.runtime.LuaFunction cos()
math.cos.
The following is the corresponding entry from the Lua Reference Manual:
math.cos (x)Returns the cosine of
x(assumed to be in radians).
math.cos functionmath.cospublic static org.classdump.luna.runtime.LuaFunction deg()
math.deg.
The following is the corresponding entry from the Lua Reference Manual:
math.deg (x)Returns the angle
x(given in radians) in degrees.
math.deg functionmath.degpublic static org.classdump.luna.runtime.LuaFunction exp()
math.exp.
The following is the corresponding entry from the Lua Reference Manual:
math.exp (x)Returns the value e
x(where e is the base of natural logarithms).
math.exp functionmath.exppublic static org.classdump.luna.runtime.LuaFunction floor()
math.floor.
The following is the corresponding entry from the Lua Reference Manual:
math.floor (x)Returns the largest integral value smaller than or equal to
x.
math.floor functionmath.floorpublic static org.classdump.luna.runtime.LuaFunction fmod()
math.fmod.
The following is the corresponding entry from the Lua Reference Manual:
math.fmod (x, y)Returns the remainder of the division of
xbyythat rounds the quotient towards zero. (integer/float)
math.fmod functionmath.fmodpublic static org.classdump.luna.runtime.LuaFunction log()
math.log.
The following is the corresponding entry from the Lua Reference Manual:
math.log (x [, base])Returns the logarithm of
xin the given base. The default forbaseis e (so that the function returns the natural logarithm ofx).
math.log functionmath.logpublic static org.classdump.luna.runtime.LuaFunction max()
math.max.
The following is the corresponding entry from the Lua Reference Manual:
math.max (x, ···)Returns the argument with the maximum value, according to the Lua operator <. (integer/float)
math.max functionmath.maxpublic static org.classdump.luna.runtime.LuaFunction min()
math.min.
The following is the corresponding entry from the Lua Reference Manual:
math.min (x, ···)Returns the argument with the minimum value, according to the Lua operator <. (integer/float)
math.min functionmath.minpublic static org.classdump.luna.runtime.LuaFunction modf()
math.modf.
The following is the corresponding entry from the Lua Reference Manual:
math.modf (x)Returns the integral part of
xand the fractional part ofx. Its second result is always a float.
math.modf functionmath.modfpublic static org.classdump.luna.runtime.LuaFunction rad()
math.rad.
The following is the corresponding entry from the Lua Reference Manual:
math.rad (x)Returns the angle
x(given in degrees) in radians.
math.rad functionmath.radpublic static org.classdump.luna.runtime.LuaFunction random(Random random)
math.random that uses the argument random
as a random number generator.
The following is the corresponding entry from the Lua Reference Manual:
math.random ([m [, n]])When called without arguments, returns a uniform pseudo-random real number in the range [0,1). When called with an integer number
m,math.randomreturns a uniform pseudo-random integer in the range [1, m]. When called with two integer numbersmandn,math.randomreturns a uniform pseudo-random integer in the range [m, n].This function is an interface to the simple pseudo-random generator function
randprovided by Standard C. (No guarantees can be given for its statistical properties.)
random - the random number generator, must not be nullmath.random functionNullPointerException - if random is nullmath.randompublic static org.classdump.luna.runtime.LuaFunction randomseed(Random random)
math.randomseed that sets the seed of the random
generator random.
The following is the corresponding entry from the Lua Reference Manual:
math.randomseed (x)Sets
xas the "seed" for the pseudo-random generator: equal seeds produce equal sequences of numbers.
random - the random number generator, must not be nullmath.randomseed functionNullPointerException - if random is nullmath.randomseedpublic static org.classdump.luna.runtime.LuaFunction sin()
math.sin.
The following is the corresponding entry from the Lua Reference Manual:
math.sin (x)Returns the sine of
x(assumed to be in radians).
math.sin functionmath.sinpublic static org.classdump.luna.runtime.LuaFunction sqrt()
math.sqrt.
The following is the corresponding entry from the Lua Reference Manual:
math.sqrt (x)Returns the square root of
x. (You can also use the expressionx^0.5to compute this value.)
math.sqrt functionmath.sqrtpublic static org.classdump.luna.runtime.LuaFunction tan()
math.tan.
The following is the corresponding entry from the Lua Reference Manual:
math.tan (x)Returns the tangent of
x(assumed to be in radians).
math.tan functionmath.tanpublic static org.classdump.luna.runtime.LuaFunction tointeger()
math.tointeger.
The following is the corresponding entry from the Lua Reference Manual:
math.tointeger (x)If the value
xis convertible to an integer, returns that integer. Otherwise, returns nil.
math.tointeger functionmath.tointegerpublic static org.classdump.luna.runtime.LuaFunction type()
math.type.
The following is the corresponding entry from the Lua Reference Manual:
math.type (x)Returns
"integer"ifxis an integer,"float"if it is a float, or nil ifxis not a number.
math.type functionmath.typepublic static org.classdump.luna.runtime.LuaFunction ult()
math.ult.
The following is the corresponding entry from the Lua Reference Manual:
math.ult (m, n)Returns a boolean, true if integer
mis below integernwhen they are compared as unsigned integers.
math.ult functionmath.ultpublic static void installInto(org.classdump.luna.StateContext context,
org.classdump.luna.Table env,
Random random)
env in the state
context context, with the random number generator random.
random may be null, in which case the functions random
and randomseed will not be installed.
If env.package.loaded is a table, adds the library table
to it with the key "math", using raw access.
context - the state context, must not be nullenv - the global environment, must not be nullrandom - the random number generator, may be nullNullPointerException - if context or env is nullpublic static void installInto(org.classdump.luna.StateContext context,
org.classdump.luna.Table env)
env in the state
context context, with a new random number generator of class Random.
To specify the random number generator or exclude random-related functions,
use installInto(StateContext, Table, Random).
context - the state context, must not be nullenv - the global environment, must not be nullNullPointerException - if context or env is nullCopyright © 2016–2017. All rights reserved.