Lua4z
A binary distribution of Lua for z/OS, with batteries

Module math

Mathematical standard library.

Functions

abs (x) Returns the absolute value of x.
acos (x) Returns the arc cosine of x (in radians).
asin (x) Returns the arc sine of x (in radians).
atan (x) Returns the arc tangent of x (in radians).
atan2 (y, x) Returns the arc tangent of y/x (in radians), but uses the signs of both parameters to find the quadrant of the result.
ceil (x) Returns the smallest integer larger than or equal to x.
cos (x) Returns the cosine of x (assumed to be in radians).
cosh (x) Returns the hyperbolic cosine of x.
deg (x) Returns the angle x (given in radians) in degrees.
exp (x) Returns the value e^x.
floor (x) Returns the largest integer smaller than or equal to x.
fmod (x, y) Returns the remainder of the division of x by y that rounds the quotient towards zero.
frexp (x) Returns m and e such that x = m2^e, e is an integer and the absolute value of m is in the range [0.5, 1) (or zero when x is zero).
ldexp (m, e) Returns m2^e (e should be an integer).
log (x) Returns the natural logarithm of x.
log10 (x) Returns the base-10 logarithm of x.
max (x, ...) Returns the maximum value among its arguments.
min (x, ...) Returns the minimum value among its arguments.
modf (x) Returns two numbers, the integral part of x and the fractional part of x.
pow (x, y) Returns x^y.
rad (x) Returns the angle x (given in degrees) in radians.
random (m, n) This function is an interface to the simple pseudo-random generator function rand provided by ANSI C.
randomseed (x) Sets x as the "seed" for the pseudo-random generator: equal seeds produce equal sequences of numbers.
sin (x) Returns the sine of x (assumed to be in radians).
sinh (x) Returns the hyperbolic sine of x.
sqrt (x) Returns the square root of x.
tan (x) Returns the tangent of x (assumed to be in radians).
tanh (x) Returns the hyperbolic tangent of x.

Functions

abs (x)
Returns the absolute value of x.

Parameters:

  • x
acos (x)
Returns the arc cosine of x (in radians).

Parameters:

  • x
asin (x)
Returns the arc sine of x (in radians).

Parameters:

  • x
atan (x)
Returns the arc tangent of x (in radians).

Parameters:

  • x
atan2 (y, 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 of x being zero.)

Parameters:

  • y
  • x
ceil (x)
Returns the smallest integer larger than or equal to x.

Parameters:

  • x
cos (x)
Returns the cosine of x (assumed to be in radians).

Parameters:

  • x
cosh (x)
Returns the hyperbolic cosine of x.

Parameters:

  • x
deg (x)
Returns the angle x (given in radians) in degrees.

Parameters:

  • x
exp (x)
Returns the value e^x.

Parameters:

  • x
floor (x)
Returns the largest integer smaller than or equal to x.

Parameters:

  • x
fmod (x, y)
Returns the remainder of the division of x by y that rounds the quotient towards zero.

Parameters:

  • x
  • y
frexp (x)
Returns m and e such that x = m2^e, e is an integer and the absolute value of m is in the range [0.5, 1) (or zero when x is zero).

Parameters:

  • x
ldexp (m, e)
Returns m2^e (e should be an integer).

Parameters:

  • m
  • e
log (x)
Returns the natural logarithm of x.

Parameters:

  • x
log10 (x)
Returns the base-10 logarithm of x.

Parameters:

  • x
max (x, ...)
Returns the maximum value among its arguments.

Parameters:

  • x
  • ...
min (x, ...)
Returns the minimum value among its arguments.

Parameters:

  • x
  • ...
modf (x)
Returns two numbers, the integral part of x and the fractional part of x.

Parameters:

  • x
pow (x, y)
Returns x^y. (You can also use the expression x^y to compute this value.)

Parameters:

  • x
  • y
rad (x)
Returns the angle x (given in degrees) in radians.

Parameters:

  • x
random (m, n)
This function is an interface to the simple pseudo-random generator function rand provided by ANSI C. (No guarantees can be given for its statistical properties.) When called without arguments, returns a uniform pseudo-random real number in the range [0,1). When called with an integer number m, math.random returns a uniform pseudo-random integer in the range [1, m]. When called with two integer numbers m and n, math.random returns a uniform pseudo-random integer in the range [m, n].

Parameters:

  • m
  • n
randomseed (x)
Sets x as the "seed" for the pseudo-random generator: equal seeds produce equal sequences of numbers.

Parameters:

  • x
sin (x)
Returns the sine of x (assumed to be in radians).

Parameters:

  • x
sinh (x)
Returns the hyperbolic sine of x.

Parameters:

  • x
sqrt (x)
Returns the square root of x. (You can also use the expression x^0.5 to compute this value.)

Parameters:

  • x
tan (x)
Returns the tangent of x (assumed to be in radians).

Parameters:

  • x
tanh (x)
Returns the hyperbolic tangent of x.

Parameters:

  • x