JavaScript acos() Method
Complete Math Object Reference
Definition and Usage
The acos() method returns the arccosine of a number as a numeric value value
between 0 and PI radians.
Syntax
Parameter |
Description |
x |
Required. Must be a numeric value in the range -1 to 1 |
Tips and Notes
Note: If the parameter x is
outside the range -1 to 1, the browser will return NaN.
Note: -1 will return the value
of PI.
Example
In this example we will get the arccosine of different numbers:
<script type="text/javascript">
document.write(Math.acos(0.64) + "<br />");
document.write(Math.acos(0) + "<br />");
document.write(Math.acos(-1) + "<br />");
document.write(Math.acos(1) + "<br />");
document.write(Math.acos(2));
</script>
|
The output of the code above will be:
0.8762980611683406
1.5707963267948965
3.141592653589793
0
NaN
|
Try-It-Yourself Demos
acos()
How to use acos() to get the arccosine of different numbers.
Complete Math Object Reference
Learn XML with <oXygen/> XML Editor - Free Trial!
|
|
oXygen helps you learn to define,
edit, validate and transform XML documents. Supported technologies include XML Schema,
DTD, Relax NG, XSLT, XPath, XQuery, CSS.
Understand in no time how XSLT and XQuery work by using the intuitive oXygen debugger!
Do you have any XML related questions? Get free answers from the oXygen
XML forum
and from the video
demonstrations.
Download a FREE 30-day trial today!
|
|