Visit Mozilla.org

Core JavaScript 1.5 Reference:Global Objects:Math:acos

From MDC


Contents

[edit] Summary

Returns the arccosine (in radians) of a number.

Method of Math

Static

Implemented in: JavaScript 1.0, NES 2.0
ECMA Version: ECMA-262

[edit] Syntax

Math.acos(x)

[edit] Parameters

x 
A number.

[edit] Description

The acos method returns a numeric value between 0 and pi radians for x between -1 and 1. If the value of number is outside this range, it returns NaN.

acos is a static method of Math, so you always use it as Math.acos(), rather than as a method of a Math object you created.

[edit] Examples

[edit] Example: Using Math.acos

The following function returns the arccosine of the variable x:

function getAcos(x) {
   return Math.acos(x)
}

If you pass -1 to getAcos, it returns 3.141592653589793; if you pass 2, it returns NaN because 2 is out of range.

[edit] See Also

asin, atan, atan2, cos, sin, tan