Home > Web Front-end > JS Tutorial > body text

javascript acos 方法计算反余弦值

WBOY
Release: 2016-06-01 09:54:39
Original
1342 people have browsed it

acos 方法返回数的反余弦值。

基本语法

<code class="language-javascript">Math.acos(number)</code>
Copy after login

参数介绍

必选项number 参数是需要计算反余弦值的数值表达式。必须是 -1.0到1.0 之间的数。如果参数 number 超过了这个范围,那么将返回 NaN。

返回值

返回值为 number 参数的反余弦值。 

需要注意的两点:

  1. 如果参数 number 超过了 -1.0 到 1.0 的范围,那么将返回 NaN。
  2. 如果参数 number 取值 -1,那么将返回 PI。
  3. 如果参数是非数值,则返回NAN。

实例:

<code class="language-javascript"><script type="text/javascript">
document.write(Math.acos(0.32) + "<br />")
document.write(Math.acos(0) + "<br />")
document.write(Math.acos(-1) + "<br />")
document.write(Math.acos(1) + "<br />")
document.write(Math.acos(4)+ "<br />")
document.write(Math.acos("s"))//NAN
</script></code>
Copy after login

在线运行

运行结果:

<code class="language-javascript">1.2450668395002664
1.5707963267948966
3.141592653589793
0
NaN
NaN</code>
Copy after login

 

Related labels:
js
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!