This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

Math

Summary

An intrinsic object that provides basic mathematics functionality and constants.

Syntax

Math. [{ property | method }]
property
Required. Name of one of the properties of the Math. object.
method
Required. Name of one of the methods of the Math. object.

Remarks

The Math object cannot be created using the new operator, and gives an error if you attempt to do so. The scripting engine creates it when the engine is loaded. All of its methods and properties are available to your script at all times.

Constants

The following table lists the constants of the Math object.

ConstantDescription
Math.E ConstantThe mathematical constant e. This is Euler’s number, the base of natural logarithms.
Math.LN2 ConstantThe natural logarithm of 2.
Math.LN10 ConstantThe natural logarithm of 10.
Math.LOG2E ConstantThe base-2 logarithm of e.
Math.LOG10E ConstantThe base-10 logarithm of e.
Math.PI ConstantPi. This is the ratio of the circumference of a circle to its diameter.
Math.SQRT1_2 ConstantThe square root of 0.5, or, equivalently, one divided by the square root of 2.
Math.SQRT2 ConstantThe square root of 2.

Functions

The following table lists the functions of the Math object.

FunctionDescription
Math.abs FunctionReturns the absolute value of a number.
Math.acos FunctionReturns the arccosine of a number.
Math.asin FunctionReturns the arcsine of a number.
Math.atan FunctionReturns the arctangent of a number.
Math.atan2 FunctionReturns the angle (in radians) from the X axis to a point represented by the supplied y and x coordinates.
Math.ceil FunctionReturns the smallest integer that is greater than or equal to the supplied numeric expression.
Math.cos FunctionReturns the cosine of a number.
Math.exp FunctionReturns e (the base of natural logarithms) raised to a power.
Math.floor FunctionReturns the greatest integer that is less than or equal to the supplied numeric expression.
Math.log FunctionReturns the natural logarithm of a number.
Math.max FunctionReturns the greater of two supplied numeric expressions.
Math.min FunctionReturns the lesser of two supplied numbers.
Math.pow FunctionReturns the value of a base expression raised to a specified power.
Math.random FunctionReturns a pseudorandom number between 0 and 1.
Math.round FunctionReturns a specified numeric expression rounded to the nearest integer.
Math.sin FunctionReturns the sine of a number.
Math.sqrt FunctionReturns the square root of a number.
Math.tan FunctionReturns the tangent of a number.

See also

Other articles

Attributions

  • Microsoft Developer Network: Article