TopLevel
Class Math
Object
Math
Mathematical functions and constants.
Constants
E  :  Number
The constant e, which is the base of natural logarithms.
LN10  :  Number
The natural logarithm of 10.
LN2  :  Number
The natural logarithm of 2.
LOG10E  :  Number
The base-10 logarithm of e.
LOG2E  :  Number
The base-2 logarithm of e.
PI  :  Number
The constant for PI.
SQRT1_2  :  Number
1 divided by the square root of 2.
SQRT2  :  Number
The square root of 2.
Constructor Summary
Math()
Method Summary
static abs(x : Number) : Number
Returns the absolute value of x.
static acos(x : Number) : Number
Returns an approximation to the arc cosine of x.
static asin(x : Number) : Number
Returns an approximation to the arc sine of x.
static atan(x : Number) : Number
Returns an approximation to the arc tangent of x.
static atan2(y : Number, x : Number) : Number
Returns an approximation to the arc tangent of the quotient y/x of the arguments y and x, where the signs of y and x are used to determine the quadrant of the result.
static ceil(x : Number) : Number
Returns the smallest (closest to -∞) number value that is not less than x and is equal to a mathematical integer.
static cos(x : Number) : Number
Returns an approximation to the cosine of x.
static exp(x : Number) : Number
Returns an implementation-dependent approximation to the exponential function of x (e raised to the power of x, where e is the base of the natural logarithms).
static floor(x : Number) : Number
Returns the greatest (closest to +∞) number value that is not greater than x and is equal to a mathematical integer.
static log(x : Number) : Number
Returns an implementation-dependent approximation to the natural logarithm of x.
static max(values : Number...) : Number
Returns the largest specified values.
static min(values : Number...) : Number
Returns the smallest of the specified values.
static pow(x : Number, y : Number) : Number
Returns an approximation to the result of raising x to the power y.
static random() : Number
Returns a number value with positive sign, greater than or equal to 0 but less than 1, chosen randomly or pseudo randomly with approximately uniform distribution over that range, using an implementation-dependent algorithm or strategy.
static round(x : Number) : Number
Returns the number value that is closest to x and is equal to a mathematical integer.
static sin(x : Number) : Number
Returns an approximation to the sine of x.
static sqrt(x : Number) : Number
Returns an approximation to the square root of x.
static tan(x : Number) : Number
Returns an approximation to the tangent of x.
Methods inherited from class Object
Constructor Detail
Math
public Math()

Method Detail
abs
static abs(x : Number) : Number
Returns the absolute value of x. The result has the same magnitude as x but has positive sign.
  • If x is NaN, the result is NaN.
  • If x is -0, the result is +0.
  • If x is -∞, the result is +∞.
Parameters:
x - the Number to operate on.
Returns:
the absolute value of x.

acos
static acos(x : Number) : Number
Returns an approximation to the arc cosine of x. The result is expressed in radians and ranges from +0 to +p.
  • If x is NaN, the result is NaN.
  • If x is greater than 1, the result is NaN.
  • If x is less than -1, the result is NaN.
  • If x is exactly 1, the result is +0.
Parameters:
x - the Number to operate on.
Returns:
an approximation to the arc cosine of x.

asin
static asin(x : Number) : Number
Returns an approximation to the arc sine of x. The result is expressed in radians and ranges from -p/2 to +p/2.
  • If i is NaN, the result is NaN
  • If i is greater than 1, the result is NaN.
  • If i is less than -1, the result is NaN.
  • If i is +0, the result is +0.
  • If i is -0, the result is -0.
Parameters:
x - the Number to operate on.
Returns:
an approximation to the arc sine of x.

atan
static atan(x : Number) : Number
Returns an approximation to the arc tangent of x. The result is expressed in radians and ranges from -p/2 to +p/2.
  • If x is NaN, the result is NaN.
  • If x is +0, the result is +0.
  • If x is -0, the result is -0.
  • If x is +∞, the result is an approximation to +p/2.
  • If x is -∞, the result is an approximation to -p/2.
Parameters:
x - the Number to operate on.
Returns:
an approximation to the arc tangent of x.

atan2
static atan2(y : Number, x : Number) : Number
Returns an approximation to the arc tangent of the quotient y/x of the arguments y and x, where the signs of y and x are used to determine the quadrant of the result. Note that it is intentional and traditional for the two-argument arc tangent function that the argument named y be first and the argument named x be second. The result is expressed in radians and ranges from -p to +p.
  • If either x or y is NaN, the result is NaN.
  • If y>0 and x is +0, the result is an implementation-dependent approximation to +p/2.
  • If y>0 and x is -0, the result is an implementation-dependent approximation to +p/2.
  • If y is +0 and x>0, the result is +0.
  • If y is +0 and x is +0, the result is +0.
  • If y is +0 and x is -0, the result is an implementation-dependent approximation to +p.
  • If y is +0 and X<0, the result is an implementation-dependent approximation to +p.
  • If y is -0 and x>0, the result is -0.
  • If y is -0 and x is +0, the result is -0.
  • If y is -0 and x is -0, the result is an implementation-dependent approximation to -p.
  • If y is -0 and X<0, the result is an implementation-dependent approximation to -p.
  • If y<0 and x is +0, the result is an implementation-dependent approximation to -p/2.
  • If y<0 and x is -0, the result is an implementation-dependent approximation to -p/2.
  • If y>0 and y is finite and x is +∞, the result is +0.
  • If y>0 and y is finite and x is -∞, the result if an implementation-dependent approximation to +p.
  • If y<0 and y is finite and x is +∞, the result is -0.
  • If y<0 and y is finite and x is -∞, the result is an implementation-dependent approximation to -p.
  • If y is +∞ and x is finite, the result is an implementation-dependent approximation to +p/2.
  • If y is -∞ and x is finite, the result is an implementation-dependent approximation to -p/2.
  • If y is +∞ and x is +∞, the result is an implementation-dependent approximation to +p/4.
  • If y is +∞ and x is -∞, the result is an implementation-dependent approximation to +3p/4.
  • If y is -∞ and x is +∞, the result is an implementation-dependent approximation to -p/4.
  • If y is -∞ and x is -∞, the result is an implementation-dependent approximation to -3p/4.
Parameters:
y - the first argument.
x - the second argument.
Returns:
approximation to the arc tangent of the quotient y/x of the arguments y and x, where the signs of y and x are used to determine the quadrant of the result.

ceil
static ceil(x : Number) : Number
Returns the smallest (closest to -∞) number value that is not less than x and is equal to a mathematical integer. If x is already an integer, the result is x.
  • If x is NaN, the result is NaN.
  • If x is +0, the result is +0.
  • If x is -0, the result is -0.
  • If x is +∞, the result is +∞.
  • If x is -∞, the result is -∞.
  • If x is less than 0 but greater than -1, the result is -0.
The value of Math.ceil(x) is the same as the value of -Math.floor(-x).
Parameters:
x - the Number to operate on.
Returns:
the smallest (closest to -∞) number value that is not less than x and is equal to a mathematical integer.

cos
static cos(x : Number) : Number
Returns an approximation to the cosine of x. The argument is expressed in radians.
  • If x is NaN, the result is NaN.
  • If x is +0, the result is 1.
  • If x is -0, the result is 1.
  • If x is +∞, the result is NaN.
  • If x is -∞, the result is NaN.
Parameters:
x - the Number to operate on.
Returns:
an approximation to the cosine of x.

exp
static exp(x : Number) : Number
Returns an implementation-dependent approximation to the exponential function of x (e raised to the power of x, where e is the base of the natural logarithms).
  • If x is NaN, the result is NaN.
  • If x is +0, the result is 1.
  • If x is -0, the result is 1.
  • If x is +∞, the result is +∞.
  • If x is -∞, the result is +0.
Parameters:
x - the Number to operate on.
Returns:
an implementation-dependent approximation to the exponential function of x.

floor
static floor(x : Number) : Number
Returns the greatest (closest to +∞) number value that is not greater than x and is equal to a mathematical integer. If x is already an integer, the result is x.
  • If x is NaN, the result is NaN.
  • If x is +0, the result is +0.
  • If x is -0, the result is -0.
  • If x is +∞, the result is +∞.
  • If x is -∞, the result is -∞.
  • If x is greater than 0 but less than 1, the result is +0.
The value of Math.floor(x) is the same as the value of -Math.ceil(-x).
Parameters:
x - the Number to operate on.
Returns:
the greatest (closest to +∞) number value that is not greater than x and is equal to a mathematical integer.

log
static log(x : Number) : Number
Returns an implementation-dependent approximation to the natural logarithm of x.
  • If x is NaN, the result is NaN.
  • If x is less than 0, the result is NaN.
  • If x is +0 or -0, the result is -∞.
  • If x is 1, the result is +0.
  • If x is +∞, the result is +∞.
Parameters:
x - the Number to operate on.
Returns:
an implementation-dependent approximation to the natural logarithm of x.

max
static max(values : Number...) : Number
Returns the largest specified values. If no arguments are given, the result is -∞. If any value is NaN, the result is NaN.
Parameters:
values - zero or more values.
Returns:
the largest of the specified values.

min
static min(values : Number...) : Number
Returns the smallest of the specified values. If no arguments are given, the result is +∞. If any value is NaN, the result is NaN.
Parameters:
values - zero or more values.
Returns:
the smallest of the specified values.

pow
static pow(x : Number, y : Number) : Number
Returns an approximation to the result of raising x to the power y.
  • If y is NaN, the result is NaN.
  • If y is +0, the result is 1, even if x is NaN.
  • If y is -0, the result is 1, even if x is NaN.
  • If x is NaN and y is nonzero, the result is NaN.
  • If abs(x)>1 and y is +∞, the result is +∞.
  • If abs(x)>1 and y is -∞, the result is +0.
  • If abs(x)==1 and y is +∞, the result is NaN.
  • If abs(x)==1 and y is -∞, the result is NaN.
  • If abs(x)<1 and y is +∞, the result is +0.
  • If abs(x)<1 and y is -∞, the result is +∞.
  • If x is +∞ and y>0, the result is +∞.
  • If x is +∞ and y<0, the result is +0.
  • If x is -∞ and y>0 and y is an odd integer, the result is -∞.
  • If x is -∞ and y>0 and y is not an odd integer, the result is +∞.
  • If x is -∞ and y<0 and y is an odd integer, the result is -0.
  • If x is -∞ and y<0 and y is not an odd integer, the result is +0.
  • If x is +0 and y>0, the result is +0.
  • If x is +0 and y<0, the result is +∞.
  • If x is -0 and y>0 and y is an odd integer, the result is -0.
  • If x is -0 and y>0 and y is not an odd integer, the result is +0.
  • If x is -0 and y<0 and y is an odd integer, the result is -∞.
  • If x is -0 and y<0 and y is not an odd integer, the result is +∞.
  • If X<0 and x is finite and y is finite and y is not an integer, the result is NaN.
Parameters:
x - a Number that will be raised to the power of y.
y - the power by which x will be raised.
Returns:
an approximation to the result of raising x to the power y.

random
static random() : Number
Returns a number value with positive sign, greater than or equal to 0 but less than 1, chosen randomly or pseudo randomly with approximately uniform distribution over that range, using an implementation-dependent algorithm or strategy.
Returns:
a Number greater than or equal to 0 but less than 1.

round
static round(x : Number) : Number
Returns the number value that is closest to x and is equal to a mathematical integer. If two integer number values are equally close to x, then the result is the number value that is closer to +∞. If x is already an integer, the result is x.
  • If x is NaN, the result is NaN.
  • If x is +0, the result is +0.
  • If x is -0, the result is -0.
  • If x is +∞, the result is +∞.
  • If x is -∞, the result is -∞.
  • If x is greater than 0 but less than 0.5, the result is +0.
  • If x is less than 0 but greater than or equal to -0.5, the result is -0.
Math.round(3.5) returns 4, but Math.round(-3.5) returns -3. The value of Math.round(x) is the same as the value of Math.floor(x+0.5), except when x is -0 or is less than 0 but greater than or equal to -0.5; for these cases Math.round(x) returns -0, but Math.floor(x+0.5) returns +0.
Parameters:
x - the Number to operate on.
Returns:
the number value that is closest to x and is equal to a mathematical integer.

sin
static sin(x : Number) : Number
Returns an approximation to the sine of x. The argument is expressed in radians.
  • If x is NaN, the result is NaN.
  • If x is +0, the result is +0.
  • If x is -0, the result is -0.
  • If x is +∞ or -∞, the result is NaN.
Parameters:
x - the Number to operate on.
Returns:
an approximation to the sine of x.

sqrt
static sqrt(x : Number) : Number
Returns an approximation to the square root of x.
  • If x is NaN, the result is NaN.
  • If x isless than 0, the result is NaN.
  • If x is +0, the result is +0.
  • If x is -0, the result is -0.
  • If x is +∞, the result is +∞.
Parameters:
x - the Number to operate on.
Returns:
an approximation to the square root of x.

tan
static tan(x : Number) : Number
Returns an approximation to the tangent of x. The argument is expressed in radians.
  • If x is NaN, the result is NaN.
  • If x is +0, the result is +0.
  • If x is -0, the result is -0.
  • If x is +∞ or -∞, the result is NaN.
Parameters:
x - the Number to operate on.
Returns:
an approximation to the tangent of x.

X Privacy Update: We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used. By continuing to use this site you are giving us your consent to do this. Privacy Policy.