MathNN 2 IE 3 ECMA 1  

  

The Math object is used only in its static object form as a library of math constant values and (mostly trigonometric) operations. As a result, there is no constructor function. Math object properties are constant values, while methods return a numeric value reflecting some math operation on a value; the original value is not altered when the method is invoked.

 

Invoking a Math object property or method adheres to the following syntax:

Math.propertyName
Math.method(param1[, param2])
 

Be sure to observe the uppercase "M" in the Math object in script statements. All expressions involving the Math object evaluate to or return a value.

 
Properties
 
ELN10LN2LOG10ELOG2EPISQRT1_2SQRT2
 
Methods
 
abs( )acos( )asin( )atan( )atan2( )ceil( )
cos( )exp( )floor( )log( )max( )min( )
pow( )random( )round( )sin( )sqrt( )tan( )
ENN 2 IE 3 ECMA 1  

Read-only  

Returns Euler's constant.

 
Example
 
var num = Math.E;
 
Value

2.718281828459045

LN2NN 2 IE 3 ECMA 1  

Read-only  

Returns the natural logarithm of 2.

 
Example
 
var num = Math.LN2;
 
Value

0.6931471805599453

LN10NN 2 IE 3 ECMA 1  

Read-only  

Returns the natural logarithm of 10.

 
Example
 
var num = Math.LN10;
 
Value

2.302585092994046

LOG2ENN 2 IE 3 ECMA 1  

Read-only  

Returns the log base-2 of Euler's constant.

 
Example
 
var num = Math.LOG2E;
 
Value

1.4426950408889634

LOG10ENN 2 IE 3 ECMA 1  

Read-only  

Returns the log base-10 of Euler's constant.

 
Example
 
var num = Math.LOG10E;
 
Value

0.4342944819032518

PINN 2 IE 3 ECMA 1  

Read-only  

Returns the value of .

 
Example
 
var num = Math.PI;
 
Value

3.141592653589793

SQRT1_2NN 2 IE 3 ECMA 1  

Read-only  

Returns the square root of 0.5.

 
Example
 
var num = Math.SQRT1_2;
 
Value

0.7071067811865476

SQRT2NN 2 IE 3 ECMA 1  

Read-only  

Returns the square root of 2.

 
Example
 
var num = Math.SQRT2;
 
Value

1.4142135623730951

abs( )NN 2 IE 3 ECMA 1  

abs(number)

  

Returns the absolute value of the number passed as a parameter.

 
Parameters
 
  • Any number.
 
Returned Value

Positive number or zero.

acos( )NN 2 IE 3 ECMA 1  

acos(number)

  

Returns the arc cosine (in radians) of the number passed as a parameter.

 
Parameters
 
  • Any number from -1 to 1.
 
Returned Value

Number.

asin( )NN 2 IE 3 ECMA 1  

asin(number)

  

Returns the arc sine (in radians) of the number passed as a parameter.

 
Parameters
 
  • Any number from -1 to 1.
 
Returned Value

Number.

atan( )NN 2 IE 3 ECMA 1  

atan(number)

  

Returns the arc tangent (in radians) of the number passed as a parameter.

 
Parameters
 
  • Any number between negative infinity and infinity.
 
Returned Value

Number.

atan2( )NN 2 IE 4 ECMA 1  

atan2(x, y)

  

Returns the angle (in radians) of angle formed by a line to Cartesian point x, y.

 
Parameters
 
  • Any number.
  • Any number.
 
Returned Value

Number between - and .

ceil( )NN 2 IE 3 ECMA 1  

ceil(number)

  

Returns the next higher integer that is greater than or equal to the number passed as a parameter.

 
Parameters
 
  • Any number.
 
Returned Value

Integer.

cos( )NN 2 IE 3 ECMA 1  

cos(number)

  

Returns the cosine of the number passed as a parameter.

 
Parameters
 
  • Any number.
 
Returned Value

Number.

exp( )NN 2 IE 3 ECMA 1  

exp(number)

  

Returns the value of Euler's constant to the power of the number passed as a parameter.

 
Parameters
 
  • Any number.
 
Returned Value

Number.

floor( )NN 2 IE 3 ECMA 1  

floor(number)

  

Returns the next lower integer that is less than or equal to the number passed as a parameter.

 
Parameters
 
  • Any number.
 
Returned Value

Integer.

log( )NN 2 IE 3 ECMA 1  

log(number)

  

Returns the natural logarithm (base e) of the number passed as a parameter.

 
Parameters
 
  • Any number.
 
Returned Value

Number.

max( )NN 2 IE 3 ECMA 1  

max(number1, number2)

  

Returns the greater value of the two parameters.

 
Parameters
 
  • Any number.
  • Any number.
 
Returned Value

Number.

min( )NN 2 IE 3 ECMA 1  

min(number1, number2)

  

Returns the lesser value of the two parameters.

 
Parameters
 
  • Any number.
  • Any number.
 
Returned Value

Number.

pow( )NN 2 IE 3 ECMA 1  

pow(number1, number2)

  

Returns the value of the first parameter raised to the power of the second parameter.

 
Parameters
 
  • Any number.
  • Any number.
 
Returned Value

Number.

random( )NN 2 IE 3 ECMA 1  

  

Returns a pseudo-random number between 0 and 1. To calculate a pseudo-random integer between zero and another maximum value, use the formula:

Math.floor(Math.random( ) * (n+1))

where n is the top integer of the acceptable range. To calculate a pseudo-random integer between a range starting with a number other than zero, use the formula:

Math.floor(Math.random( ) * n - m + 1) + m

where m is the lowest integer of the acceptable range and n equals the maximum value of the range. Note that the Math.random( ) method does not work in the Windows and Macintosh versions of Navigator 2.

 
Parameters

None.

 
Returned Value

Number from 0 up to, but not including, 1.

round( )NN 2 IE 3 ECMA 1  

round(number)

  

Returns an integer that follows rounding rules. If the value of the passed parameter is greater than or equal to x.5, the returned value is x + 1; otherwise, the returned value is x.

 
Parameters
 
  • Any number.
 
Returned Value

Integer.

sin( )NN 2 IE 3 ECMA 1  

sin(number)

  

Returns the sine (in radians) of the number passed as a parameter.

 
Parameters
 
  • Any number.
 
Returned Value

Number.

sqrt( )NN 2 IE 3 ECMA 1  

sqrt(number)

  

Returns the square root of the number passed as a parameter.

 
Parameters
 
  • Any number.
 
Returned Value

Number.

tan( )NN 2 IE 3 ECMA 1  

tan(number)

  

Returns the tangent (in radians) of the number passed as a parameter.

 
Parameters
 
  • Any number between negative infinity and infinity.
 
Returned Value

Number.