Math Class

The Math class is a top-level class whose methods and properties you can use without using a constructor.

Several of the Math class methods take the radian of an angle as an parameter. You can use the equation below to calculate radian values, or pass the equation (entering a value for degrees) for the radian parameter.
To calculate a radian value, use the following formula:
radian = Math.PI / 180 * degree

Math methods

Math.abs(x)Computes an absolute value.
Math.acos(x)Computes an arc cosine.
Math.asin(x)Computes an arc sine.
Math.atan(x)Computes an arc tangent.
Math.atan2(y,x)Computes an angle from the x-axis to the point.
Math.ceil(x)Rounds a number up to the nearest integer.
Math.cos(x)Computes a cosine.
Math.exp(x)Computes an exponential value.
Math.floor(x)Rounds a number down to the nearest integer.
Math.log(x)Computes a natural logarithm.
Math.max(x,y)Returns the larger of the two integers.
Math.min(x,y)Returns the smaller of the two integers.
Math.pow(x,y)Computes x raised to the power of the y.
Math.random()Returns a pseudo-random number between 0.0 and 1.0.
Math.round(x)Rounds to the nearest integer.
Math.sin(x)Computes a sine.
Math.sqrt(x)Computes a square root.
Math.tan(x)Computes a tangent.

Math members (constants)

Math.EEuler's constant and the base of natural logarithms (approximately 2.718).
Math.LN2The natural logarithm of 2 (approximately 0.693).
Math.LOG2EThe base 2 logarithm of e (approximately 1.442).
Math.LN2The natural logarithm of 10 (approximately 2.302).
Math.LOG10EThe base 10 logarithm of e (approximately 0.434).
Math.PIThe ratio of the circumference of a circle to its diameter (approximately 3.14159).
Math.SQRT1_2The reciprocal of the square root of 1/2 (approximately 0.707).
Math.SQRT2The square root of 2 (approximately 1.414).