Section 24.100. Math: mathematical functions and constants


24.100. Math: mathematical functions and constants

ECMAScript v1

24.100.1. Synopsis

Math.constantMath.function( )

24.100.2. Constants


Math.E

The constant e, the base of the natural logarithm.


Math.LN10

The natural logarithm of 10.


Math.LN2

The natural logarithm of 2.


Math.LOG10E

The base-10 logarithm of e.


Math.LOG2E

The base-2 logarithm of e.


Math.PI

The constant π.


Math.SQRT1_2

The number 1 divided by the square root of 2.


Math.SQRT2

The square root of 2.

24.100.3. Static Functions


Math.abs( )

Computes an absolute value.


Math.acos( )

Computes an arccosine.


Math.asin( )

Computes an arcsine.


Math.atan( )

Computes an arctangent.


Math.atan2( )

Computes the angle from the X axis to a point.


Math.ceil( )

Rounds a number up.


Math.cos( )

Computes a cosine.


Math.exp( )

Computes a power of e.


Math.floor( )

Rounds a number down.


Math.log( )

Computes a natural logarithm.


Math.max( )

Returns the larger of two numbers.


Math.min( )

Returns the smaller of two numbers.


Math.pow( )

Computes xy


Math.random( )

Computes a random number.


Math.round( )

Rounds to the nearest integer.


Math.sin( )

Computes a sine.


Math.sqrt( )

Computes a square root.


Math.tan( )

Computes a tangent.

24.100.4. Description

Math is an object that defines properties that refer to useful mathematical functions and constants. These functions and constants are invoked with syntax like this:

 y = Math.sin(x); area = radius * radius * Math.PI; 

Math is not a class of objects as Date and String are. There is no Math( ) constructor, and functions like Math.sin( ) are simply functions, not methods that operate on an object.

24.100.5. See Also

 Number 




JavaScript. The Definitive Guide
JavaScript: The Definitive Guide
ISBN: 0596101996
EAN: 2147483647
Year: 2004
Pages: 767

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net