MathNN 2   IE J1   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. 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.

ENN 2   IE J1   ECMA 1
 Read-only
 

Returns Euler's constant.

 
Example
var num = Math.E
 
Value
2.718281828459045
LN2NN 2   IE J1   ECMA 1
 Read-only
 

Returns the natural logarithm of 2.

 
Example
var num = Math.LN2
 
Value
0.6931471805599453
LN10NN 2   IE J1   ECMA 1
 Read-only
 

Returns the natural logarithm of 10.

 
Example
var num = Math.LN10
 
Value
2.302585092994046
LOG2ENN 2   IE J1   ECMA 1
 Read-only
 

Returns the log base-2 of E.

 
Example
var num = Math.LOG2E
 
Value
1.4426950408889634
LOG10ENN 2   IE J1   ECMA 1
 Read-only
 

Returns the log base-10 of E.

 
Example
var num = Math.LOG10E
 
Value
0.4342944819032518
PINN 2   IE J1   ECMA 1
 Read-only
 

Returns the value of &pgr;.

 
Example
var num = Math.PI
 
Value
3.141592653589793
SQRT1_2NN 2   IE J1   ECMA 1
 Read-only
 

Returns the square root of 0.5.

 
Example
var num = Math.SQRT1_2    
 
Value
0.7071067811865476
SQRT2NN 2   IE J1   ECMA 1
 Read-only
 

Returns the square root of 2.

 
Example
var num = Math.SQRT2    
 
Value
1.4142135623730951
abs()NN 2   IE J1   ECMA 1
abs(number) 
 

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

 
Returned Value
Positive number or zero.
 
Parameters
number Any number.
acos()NN 2   IE J1   ECMA 1
acos(number) 
 

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

 
Returned Value
Number.
 
Parameters
number Any number from -1 to 1.
asin()NN 2   IE J1   ECMA 1
asin(number) 
 

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

 
Returned Value
Number.
 
Parameters
number Any number from -1 to 1.
atan()NN 2   IE J1   ECMA 1
atan(number) 
 

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

 
Returned Value
Number.
 
Parameters
number Any number between negative infinity and infinity.
atan2()NN 2   IE J2   ECMA 1
atan2(x, y) 
 

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

 
Returned Value
Number between -&pgr; and &pgr;.
 
Parameters
x Any number.
y Any number.
ceil()NN 2   IE J1   ECMA 1
ceil(number) 
 

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

 
Returned Value
Integer.
 
Parameters
number Any number.
cos()NN 2   IE J1   ECMA 1
cos(number) 
 

Returns the cosine of the number passed as a parameter.

 
Returned Value
Number.
 
Parameters
number Any number.
exp()NN 2   IE J1   ECMA 1
exp(number) 
 

Returns the value of E to the power of the number passed as a parameter.

 
Returned Value
Number.
 
Parameters
number Any number.
floor()NN 2   IE J1   ECMA 1
floor(number) 
 

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

 
Returned Value
Integer.
 
Parameters
number Any number.
log()NN 2   IE J1   ECMA 1
log(number) 
 

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

 
Returned Value
Number.
 
Parameters
number Any number.
max()NN 2   IE J1   ECMA 1
max(number1, number2)  
 

Returns the greater value of the two parameters.

 
Returned Value
Number.
 
Parameters
number1 Any number.
number2 Any number.
min()NN 2   IE J1   ECMA 1
min(number1, number2)  
 

Returns the lesser value of the two parameters.

 
Returned Value
Number.
 
Parameters
number1 Any number.
number2 Any number.
pow()NN 2   IE J1   ECMA 1
pow(number1, number2)  
 

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

 
Returned Value
Number.
 
Parameters
number1 Any number.
number2 Any number.
random()NN 2   IE J1   ECMA 1

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

Math.round(Math.random() * n)

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

Math.round(Math.random() * n) + m

where m is the lowest integer of the acceptable range and n+m 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.

 
Returned Value
Number from 0 through 1.
 
Parameters
None.
round()NN 2   IE J1   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.

 
Returned Value
Integer.
 
Parameters
number Any number.
sin()NN 2   IE J1   ECMA 1
sin(number) 
 

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

 
Returned Value
Number.
 
Parameters
number Any number.
sqrt()NN 2   IE J1   ECMA 1
sqrt(number) 
 

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

 
Returned Value
Number.
 
Parameters
number Any number.
tan()NN 2   IE J1   ECMA 1
tan(number) 
 

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

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