2019-04-21 11:50:48 +08:00

204 lines
35 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<article id="wikiArticle">
<div></div>
<p><strong><code>Math</code></strong> 是一个内置对象, 它具有数学常数和函数的属性和方法。不是一个函数对象。</p>
<h2 id="Description" name="Description" style="margin: 0px 0px 20px; padding: 0px; border: 0px; word-wrap: break-word; font-family: 'Open Sans', Arial, sans-serif; line-height: 1; font-size: 2.14285714285714rem; letter-spacing: -1px; color: rgb(77, 78, 83); background-color: rgb(255, 255, 255);">描述</h2>
<p style="margin: 0px 0px 24px; padding: 0px; border: 0px; color: rgb(77, 78, 83); font-family: 'Open Sans', Arial, sans-serif; font-size: 14px; line-height: 21px; background-color: rgb(255, 255, 255);">与其它全局对象不同的是, <code style="font-style: normal;">Math</code> 不是一个构造器.  <code>Math</code> 的所有属性和方法都是静态的. 你用到的常数pi可以用 <code>Math.PI</code> 表示,用 <code>x</code> 作参数 <span style="font-family: courier,andale mono,monospace;">Math.sin(x)</span><font face="Consolas, Monaco, Andale Mono, monospace">调用sin函数</font>. JavaScript中的常数, 是以全精度的实数定义的.</p>
<h2 id="Properties" name="Properties" style="margin: 0px 0px 20px; padding: 0px; border: 0px; word-wrap: break-word; font-family: 'Open Sans', Arial, sans-serif; line-height: 1; font-size: 2.14285714285714rem; letter-spacing: -1px; color: rgb(77, 78, 83); background-color: rgb(255, 255, 255);">属性</h2>
<dl>
<dt><a href="Reference/Global_Objects/Math/E" title="Math.E 属性表示自然对数的底数或称为基数e约等于 2.718。"><code>Math.E</code></a></dt>
<dd>欧拉常数,也是自然对数的底数, 约等于 2.718.</dd>
<dt><a href="Reference/Global_Objects/Math/LN2" title="Math.LN2 属性表示 2 的自然对数,约为 0.693"><code>Math.LN2</code></a></dt>
<dd>2的自然对数, 约等于0.693.</dd>
<dt><a href="Reference/Global_Objects/Math/LN10" title="Math.LN10 属性表示 10 的自然对数,约为 2.302"><code>Math.LN10</code></a></dt>
<dd>10的自然对数, 约等于 2.303.</dd>
<dt><a href="Reference/Global_Objects/Math/LOG2E" title="Math.LOG2E 属性表示以 2 为底数e 的对数,约为 1.442"><code>Math.LOG2E</code></a></dt>
<dd>以2为底E的对数, 约等于 1.443.</dd>
<dt><a href="Reference/Global_Objects/Math/LOG10E" title="Math.LOG10E 属性表示以 10 为底数e 的对数,约为 0.434"><code>Math.LOG10E</code></a></dt>
<dd>以10为底E的对数, 约等于 0.434.</dd>
<dt><a href="Reference/Global_Objects/Math/PI" title="Math.PI 表示一个圆的周长与直径的比例约为 3.14159"><code>Math.PI</code></a></dt>
<dd>圆周率,一个圆的周长和直径之比,约等于 3.14159.</dd>
<dt><a href="Reference/Global_Objects/Math/SQRT1_2" title="Math.SQRT1_2 属性表示 1/2 的平方根,约为 0.707"><code>Math.SQRT1_2</code></a></dt>
<dd>1/2的平方根, 约等于 0.707.</dd>
<dt><a href="Reference/Global_Objects/Math/SQRT2" title="Math.SQRT2 属性表示 2 的平方根,约为 1.414"><code>Math.SQRT2</code></a></dt>
<dd>2的平方根,约等于 1.414.</dd>
<dt><div class="blockIndicator inheritsbox template-jsOverrides">
<div><span style="font-weight: 700;">Properties inherited from <a href="https://developer.mozilla.orgReference/Global_Objects/Object"><code>Object</code></a>:</span></div>
<div><a class="internal" href="https://developer.mozilla.orgReference/Global_Objects/Object/Constructor"><code>constructor</code></a>, <a class="internal" href="https://developer.mozilla.orgReference/Global_Objects/Object/Parent"><code>__parent__</code></a>, <a class="internal" href="https://developer.mozilla.orgReference/Global_Objects/Object/Proto"><code>__proto__</code></a></div>
</div></dt>
</dl>
<h2 id="Methods" name="Methods" style="margin: 0px 0px 20px; padding: 0px; border: 0px; word-wrap: break-word; font-family: 'Open Sans', Arial, sans-serif; line-height: 1; font-size: 2.14285714285714rem; letter-spacing: -1px; color: rgb(77, 78, 83); background-color: rgb(255, 255, 255);">方法</h2>
<div class="note">
<p style="margin: 0px; padding: 0px; border: 0px;">需要注意的是三角函数(<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-weight: inherit; font-family: Courier, 'Andale Mono', monospace;">sin()</code>, <code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-weight: inherit; font-family: Courier, 'Andale Mono', monospace;">cos()</code>, <code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-weight: inherit; font-family: Courier, 'Andale Mono', monospace;">tan()</code>,<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-weight: inherit; font-family: Courier, 'Andale Mono', monospace;">asin()</code>, <code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-weight: inherit; font-family: Courier, 'Andale Mono', monospace;">acos()</code>, <code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-weight: inherit; font-family: Courier, 'Andale Mono', monospace;">atan()</code>, <code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-weight: inherit; font-family: Courier, 'Andale Mono', monospace;">atan2())是以弧度返回值的。可以通过除法(</code>Math.PI / 180把弧度转换为角度也可以通过其他方法来转换。</p>
</div>
<div class="note">
<p style="margin: 0px; padding: 0px; border: 0px;">需要注意的是很多数学函数都有一个精度,并且精度在不同环境下也是不相同的。这就意味着不同的浏览器会给出不同的结果,甚至相同的 JS 引擎在不同的OS或者架构下也会给出不同的结果。</p>
</div>
<dl>
<dt><a href="Reference/Global_Objects/Math/abs" title="Math.abs(x) 函数返回指定数字 “x“ 的绝对值。如下:"><code>Math.abs(x)</code></a></dt>
<dd>返回x的绝对值.</dd>
<dt><a href="Reference/Global_Objects/Math/acos" title="Math.acos() 返回一个数的反余弦值(单位为弧度),即:"><code>Math.acos(x)</code></a></dt>
<dd>返回x的反余弦值.</dd>
<dt><a class="new" href="Reference/Global_Objects/Math/acosh" rel="nofollow" title="此页面仍未被本地化, 期待您的翻译!"><code>Math.acosh(x)</code></a> <span title="这是一个实验性的 API请尽量不要在生产环境中使用它。"><i class="icon-beaker"> </i></span></dt>
<dd>返回x的反双曲余弦值.</dd>
<dt><a href="Reference/Global_Objects/Math/asin" title="Math.asin() 方法返回一个数值的反正弦(单位为弧度),即:"><code>Math.asin(x)</code></a></dt>
<dd>返回x的反正弦值.</dd>
<dt><a href="Reference/Global_Objects/Math/asinh" title="Math.asinh() 函数返回给定数字的反双曲正弦值, 即:"><code>Math.asinh(x)</code></a> <span title="这是一个实验性的 API请尽量不要在生产环境中使用它。"><i class="icon-beaker"> </i></span></dt>
<dd>返回x的反双曲正弦值.</dd>
<dt><a href="Reference/Global_Objects/Math/atan" title="Math.atan() 函数返回一个数值的反正切(以弧度为单位),即:"><code>Math.atan(x)</code></a></dt>
<dd><span style="font-size: 14.4444446563721px; line-height: 23.3333339691162px;">以介于 -PI/2 与 PI/2 弧度之间的数值来返回 x 的反正切值.</span></dd>
<dt><a href="Reference/Global_Objects/Math/atanh" title="Math.atanh() 函数返回一个数值反双曲正切值, 即:"><code>Math.atanh(x)</code></a> <span title="这是一个实验性的 API请尽量不要在生产环境中使用它。"><i class="icon-beaker"> </i></span></dt>
<dd>返回 x 的反双曲正切值<span style="font-size: 14.4444446563721px; line-height: 23.3333339691162px;">.</span></dd>
<dt><a href="Reference/Global_Objects/Math/atan2" title="Math.atan2() 返回其参数比值的反正切值。"><code>Math.atan2(y, x)</code></a></dt>
<dd>返回 y/x 的反正切值.</dd>
<dt><a href="Reference/Global_Objects/Math/cbrt" title="Math.cbrt() 函数返回任意数字的立方根."><code>Math.cbrt(x)</code></a> <span title="这是一个实验性的 API请尽量不要在生产环境中使用它。"><i class="icon-beaker"> </i></span></dt>
<dd>返回x的立方根.</dd>
<dt><a href="Reference/Global_Objects/Math/ceil" title="Math.ceil() 函数返回大于或等于一个给定数字的最小整数。"><code>Math.ceil(x)</code></a></dt>
<dd>返回x向上取整后的值.</dd>
<dt><a href="Reference/Global_Objects/Math/clz32" title="Math.clz32() 函数返回一个数字在转换成 32 无符号整形数字的二进制形式后, 开头的 0 的个数, 比如 1000000 转换成 32 位无符号整形数字的二进制形式后是 00000000000011110100001001000000, 开头的 0 的个数是 12 个, 则 Math.clz32(1000000) 返回 12."><code>Math.clz32(x)</code></a> <span title="这是一个实验性的 API请尽量不要在生产环境中使用它。"><i class="icon-beaker"> </i></span></dt>
<dd>返回一个32位整数的前导零的数量。</dd>
<dt><a href="Reference/Global_Objects/Math/cos" title="Math.cos() 函数返回一个数值的余弦值。"><code>Math.cos(x)</code></a></dt>
<dd>返回x的余弦值.</dd>
<dt><a href="Reference/Global_Objects/Math/cosh" title="Math.cosh() 函数返回数值的双曲余弦函数, 可用 constant e 表示:"><code>Math.cosh(x)</code></a> <span title="这是一个实验性的 API请尽量不要在生产环境中使用它。"><i class="icon-beaker"> </i></span></dt>
<dd>返回x的<span style="">双曲余弦值</span>.</dd>
<dt><a href="Reference/Global_Objects/Math/exp" title="Math.exp() 函数返回 exx 表示参数e 是欧拉常数Euler's constant自然对数的底数。"><code>Math.exp(x)</code></a></dt>
<dd>返回 E<span style="position: relative; top: -0.15em; vertical-align: top;">x</span>, 当x为参数,  E 是欧拉常数 (2.718...), 自然对数的底.</dd>
<dt><a href="Reference/Global_Objects/Math/expm1" title="Math.expm1() 函数返回 Ex - 1, 其中 x 是该函数的参数, E 是自然对数的底数 2.718281828459045."><code>Math.expm1(x)</code></a> <span title="这是一个实验性的 API请尽量不要在生产环境中使用它。"><i class="icon-beaker"> </i></span></dt>
<dd>返回 exp(x)-1 的值.</dd>
<dt><a href="Reference/Global_Objects/Math/floor" title="Math.floor() 返回小于或等于一个给定数字的最大整数。"><code>Math.floor(x)</code></a></dt>
<dd>返回小于x的最大整数。</dd>
<dt><a href="Reference/Global_Objects/Math/fround" title="Math.fround() 可以将任意的数字转换为离它最近的单精度浮点数形式的数字。"><code>Math.fround(x)</code></a> <span title="这是一个实验性的 API请尽量不要在生产环境中使用它。"><i class="icon-beaker"> </i></span></dt>
<dd>返回数字的最接近的单精度浮点型表示。</dd>
<dt><a href="Reference/Global_Objects/Math/hypot" title="Math.hypot() 函数返回它的所有参数的平方和的平方根,即:"><code>Math.hypot([x[,y[,…]]])</code></a> <span title="这是一个实验性的 API请尽量不要在生产环境中使用它。"><i class="icon-beaker"> </i></span></dt>
<dd>返回其参数平方和的平方根。</dd>
<dt><a href="Reference/Global_Objects/Math/imul" title="该函数返回两个参数的类C的32位整数乘法运算的运算结果."><code>Math.imul(x)</code></a> <span title="这是一个实验性的 API请尽量不要在生产环境中使用它。"><i class="icon-beaker"> </i></span></dt>
<dd>返回32位整数乘法的结果。</dd>
<dt><a href="Reference/Global_Objects/Math/log" title="Math.log() 函数返回一个数的自然对数,即:"><code>Math.log(x)</code></a></dt>
<dd>返回一个数的自然对数log<sub>e </sub>即ln</dd>
<dt><a href="Reference/Global_Objects/Math/log1p" title="Math.log1p() 函数返回一个数字加1后的自然对数 (底为 E), 既log(x+1)."><code>Math.log1p(x)</code></a> <span title="这是一个实验性的 API请尽量不要在生产环境中使用它。"><i class="icon-beaker"> </i></span></dt>
<dd><span class="sentence" id="mt1">返回 1 加上一个数字的的自然对数</span>log<sub>e </sub>即ln</dd>
<dt><a href="Reference/Global_Objects/Math/log10" title="Math.log10() 函数返回一个数字以 10 为底的对数."><code>Math.log10(x)</code></a> <span title="这是一个实验性的 API请尽量不要在生产环境中使用它。"><i class="icon-beaker"> </i></span></dt>
<dd>返回以10为底数的x的对数。</dd>
<dt><a href="Reference/Global_Objects/Math/log2" title="Math.log2() 函数返回一个数字以 2 为底的对数."><code>Math.log2(x)</code></a> <span title="这是一个实验性的 API请尽量不要在生产环境中使用它。"><i class="icon-beaker"> </i></span></dt>
<dd>返回以2为底数的x的对数。</dd>
<dt><a href="Reference/Global_Objects/Math/max" title="Math.max() 函数返回一组数中的最大值。"><code>Math.max([x[,y[,…]]])</code></a></dt>
<dd>返回0个到多个数值中最大值.</dd>
<dt><a href="Reference/Global_Objects/Math/min" title="Math.min() 返回零个或更多个数值的最小值。"><code>Math.min([x[,y[,…]]])</code></a></dt>
<dd>返回0个到多个数值中最小值.</dd>
<dt><a href="Reference/Global_Objects/Math/pow" title="Math.pow() 函数返回基数base的指数exponent次幂 baseexponent。"><code>Math.pow(x,y)</code></a></dt>
<dd>返回x的y次幂.</dd>
<dt><a href="Reference/Global_Objects/Math/random" title="Math.random() 函数返回一个浮点,  伪随机数在范围[01)也就是说从0包括0往上但是不包括1排除1然后您可以缩放到所需的范围。实现将初始种子选择到随机数生成算法;它不能被用户选择或重置。"><code>Math.random()</code></a></dt>
<dd>返回0到1之间的伪随机数.</dd>
<dt><a href="Reference/Global_Objects/Math/round" title="Math.round() 函数返回一个数字四舍五入后最接近的整数。"><code>Math.round(x)</code></a></dt>
<dd>返回四舍五入后的整数.</dd>
<dt><a href="Reference/Global_Objects/Math/sign" title="Math.sign() 函数返回一个数字的符号, 指示数字是正数,负数还是零。"><code>Math.sign(x)</code></a> <span title="这是一个实验性的 API请尽量不要在生产环境中使用它。"><i class="icon-beaker"> </i></span></dt>
<dd>返回x的符号函数, 判定x是正数,负数还是0.</dd>
<dt><a href="Reference/Global_Objects/Math/sin" title="Math.sin() 函数返回一个数值的正弦值。"><code>Math.sin(x)</code></a></dt>
<dd>返回正弦值.</dd>
<dt><a href="Reference/Global_Objects/Math/sinh" title="Math.sinh() 函数返回一个数字(单位为角度)的双曲正弦值."><code>Math.sinh(x)</code></a> <span title="这是一个实验性的 API请尽量不要在生产环境中使用它。"><i class="icon-beaker"> </i></span></dt>
<dd>返回x的双曲正弦值.</dd>
<dt><a href="Reference/Global_Objects/Math/sqrt" title="Math.sqrt() 函数返回一个数的平方根,即:"><code>Math.sqrt(x)</code></a></dt>
<dd>返回x的平方根.</dd>
<dt><a href="Reference/Global_Objects/Math/tan" title="Math.tan() 方法返回一个数值的正切值。"><code>Math.tan(x)</code></a></dt>
<dd>返回x的正切值.</dd>
<dt><a href="Reference/Global_Objects/Math/tanh" title="Math.tanh() 函数将会返回一个数的双曲正切函数值,计算如下:"><code>Math.tanh(x)</code></a> <span title="这是一个实验性的 API请尽量不要在生产环境中使用它。"><i class="icon-beaker"> </i></span></dt>
<dd>返回x的双曲正切值.</dd>
<dt><code>Math.toSource()</code> <span class="icon-only-inline" title="This API has not been standardized."><i class="icon-warning-sign"> </i></span></dt>
<dd>返回字符串 <code>"Math"</code>.</dd>
<dt><a href="Reference/Global_Objects/Math/trunc" title="Math.trunc() 方法会将数字的小数部分去掉,只保留整数部分。"><code>Math.trunc(x)</code></a> <span title="这是一个实验性的 API请尽量不要在生产环境中使用它。"><i class="icon-beaker"> </i></span></dt>
<dd>返回x的整数部分,去除小数.</dd>
<dt><div class="blockIndicator inheritsbox template-jsOverrides">
<div><span style="font-weight: 700;">Methods inherited from <a href="https://developer.mozilla.orgReference/Global_Objects/Object"><code>Object</code></a>:</span></div>
<div><a class="internal new" href="https://developer.mozilla.orgReference/Global_Objects/Object/DefineGetter" rel="nofollow"><code>__defineGetter__</code></a>, <a class="internal new" href="https://developer.mozilla.orgReference/Global_Objects/Object/DefineSetter" rel="nofollow"><code>__defineSetter__</code></a>, <a class="internal" href="https://developer.mozilla.orgReference/Global_Objects/Object/HasOwnProperty"><code>hasOwnProperty</code></a>, <a class="internal" href="https://developer.mozilla.orgReference/Global_Objects/Object/IsPrototypeOf"><code>isPrototypeOf</code></a>, <a class="internal" href="https://developer.mozilla.orgReference/Global_Objects/Object/LookupGetter"><code>__lookupGetter__</code></a>, <a class="internal new" href="https://developer.mozilla.orgReference/Global_Objects/Object/LookupSetter" rel="nofollow"><code>__lookupSetter__</code></a>, <a class="internal" href="https://developer.mozilla.orgReference/Global_Objects/Object/NoSuchMethod"><code>__noSuchMethod__</code></a>, <a class="internal" href="https://developer.mozilla.orgReference/Global_Objects/Object/PropertyIsEnumerable"><code>propertyIsEnumerable</code></a>, <a class="internal" href="https://developer.mozilla.orgReference/Global_Objects/Object/ToSource"><code>toSource</code></a>, <a class="internal" href="https://developer.mozilla.orgReference/Global_Objects/Object/ToLocaleString"><code>toLocaleString</code></a>, <a class="internal" href="https://developer.mozilla.orgReference/Global_Objects/Object/ToString"><code>toString</code></a>, <a class="internal" href="https://developer.mozilla.orgReference/Global_Objects/Object/Unwatch"><code>unwatch</code></a>, <a class="internal" href="https://developer.mozilla.orgReference/Global_Objects/Object/ValueOf"><code>valueOf</code></a>, <a class="internal" href="https://developer.mozilla.orgReference/Global_Objects/Object/Watch"><code>watch</code></a></div>
</div></dt>
</dl>
<h2 id="Specifications" name="Specifications" style="margin: 0px 0px 20px; padding: 0px; border: 0px; word-wrap: break-word; font-family: 'Open Sans', Arial, sans-serif; line-height: 1; font-size: 2.14285714285714rem; letter-spacing: -1px; color: rgb(77, 78, 83); background-color: rgb(255, 255, 255);">规范</h2>
<table class="standard-table" style="background-color: #ffffff; border-collapse: collapse; border: 2px solid #ffffff; color: #4d4e53; font-family: open sans,arial,sans-serif; font-size: 14px; line-height: 21px; margin: 0px 0px 24px; padding: 0px;">
<tbody>
<tr style="margin: 0px; padding: 0px; border: 0px;">
<th scope="col" style="margin: 0px; padding: 2px 8px 4px; border-width: 2px; border-style: solid; border-color: rgb(255, 255, 255) rgb(255, 255, 255) rgb(212, 221, 228); font-style: inherit; font-family: 'Open Sans Light', Helvetica, Arial, sans-serif; background: rgba(212, 221, 228, 0.498039);">规范</th>
<th scope="col" style="margin: 0px; padding: 2px 8px 4px; border-width: 2px; border-style: solid; border-color: rgb(255, 255, 255) rgb(255, 255, 255) rgb(212, 221, 228); font-style: inherit; font-family: 'Open Sans Light', Helvetica, Arial, sans-serif; background: rgba(212, 221, 228, 0.498039);">状态</th>
<th scope="col" style="margin: 0px; padding: 2px 8px 4px; border-width: 2px; border-style: solid; border-color: rgb(255, 255, 255) rgb(255, 255, 255) rgb(212, 221, 228); font-style: inherit; font-family: 'Open Sans Light', Helvetica, Arial, sans-serif; background: rgba(212, 221, 228, 0.498039);">说明</th>
</tr>
<tr style="margin: 0px; padding: 0px; border: 0px;">
<td style="margin: 0px; padding: 6px 8px; border: 2px solid rgb(255, 255, 255); box-shadow: rgba(212, 221, 228, 0.498039) 0px -1px 0px 0px inset; background-color: rgba(212, 221, 228, 0.14902);">ECMAScript 1st Edition.</td>
<td style="margin: 0px; padding: 6px 8px; border: 2px solid rgb(255, 255, 255); box-shadow: rgba(212, 221, 228, 0.498039) 0px -1px 0px 0px inset; background-color: rgba(212, 221, 228, 0.14902);"><span class="spec-Standard">Standard</span></td>
<td style="margin: 0px; padding: 6px 8px; border: 2px solid rgb(255, 255, 255); box-shadow: rgba(212, 221, 228, 0.498039) 0px -1px 0px 0px inset; background-color: rgba(212, 221, 228, 0.14902);">初始定义。在 JavaScript 1.1 中实现。</td>
</tr>
<tr style="margin: 0px; padding: 0px; border: 0px;">
<td style="margin: 0px; padding: 6px 8px; border: 2px solid rgb(255, 255, 255); box-shadow: rgba(212, 221, 228, 0.498039) 0px -1px 0px 0px inset; background-color: rgba(212, 221, 228, 0.247059);"><a class="external" href="https://www.ecma-international.org/ecma-262/5.1/#sec-15.8" hreflang="en" lang="en" rel="noopener">ECMAScript 5.1 (ECMA-262)<br/><small lang="zh-CN">Math</small></a></td>
<td style="margin: 0px; padding: 6px 8px; border: 2px solid rgb(255, 255, 255); box-shadow: rgba(212, 221, 228, 0.498039) 0px -1px 0px 0px inset; background-color: rgba(212, 221, 228, 0.247059);"><span class="spec-Standard">Standard</span></td>
<td style="margin: 0px; padding: 6px 8px; border: 2px solid rgb(255, 255, 255); box-shadow: rgba(212, 221, 228, 0.498039) 0px -1px 0px 0px inset; background-color: rgba(212, 221, 228, 0.247059);"> </td>
</tr>
<tr style="margin: 0px; padding: 0px; border: 0px;">
<td style="margin: 0px; padding: 6px 8px; border: 2px solid rgb(255, 255, 255); box-shadow: rgba(212, 221, 228, 0.498039) 0px -1px 0px 0px inset; background-color: rgba(212, 221, 228, 0.14902);"><a class="external" href="https://www.ecma-international.org/ecma-262/6.0/#sec-math-object" hreflang="en" lang="en" rel="noopener">ECMAScript 2015 (6th Edition, ECMA-262)<br/><small lang="zh-CN">Math</small></a></td>
<td style="margin: 0px; padding: 6px 8px; border: 2px solid rgb(255, 255, 255); box-shadow: rgba(212, 221, 228, 0.498039) 0px -1px 0px 0px inset; background-color: rgba(212, 221, 228, 0.14902);"><span class="spec-Standard">Standard</span></td>
<td style="margin: 0px; padding: 6px 8px; border: 2px solid rgb(255, 255, 255); box-shadow: rgba(212, 221, 228, 0.498039) 0px -1px 0px 0px inset; background-color: rgba(212, 221, 228, 0.14902);">New methods <a href="Reference/Global_Objects/Math/log10" title="Math.log10() 函数返回一个数字以 10 为底的对数."><code>log10()</code></a>, <a href="Reference/Global_Objects/Math/log2" title="Math.log2() 函数返回一个数字以 2 为底的对数."><code>log2()</code></a>, <a href="Reference/Global_Objects/Math/log1p" title="Math.log1p() 函数返回一个数字加1后的自然对数 (底为 E), 既log(x+1)."><code>log1p()</code></a>, <a href="Reference/Global_Objects/Math/expm1" title="Math.expm1() 函数返回 Ex - 1, 其中 x 是该函数的参数, E 是自然对数的底数 2.718281828459045."><code>expm1()</code></a>, <a href="Reference/Global_Objects/Math/cosh" title="Math.cosh() 函数返回数值的双曲余弦函数, 可用 constant e 表示:"><code>cosh()</code></a>, <a href="Reference/Global_Objects/Math/sinh" title="Math.sinh() 函数返回一个数字(单位为角度)的双曲正弦值."><code>sinh()</code></a>, <a href="Reference/Global_Objects/Math/tanh" title="Math.tanh() 函数将会返回一个数的双曲正切函数值,计算如下:"><code>tanh()</code></a>, <a class="new" href="Reference/Global_Objects/Math/acosh" rel="nofollow" title="此页面仍未被本地化, 期待您的翻译!"><code>acosh()</code></a>, <a href="Reference/Global_Objects/Math/asinh" title="Math.asinh() 函数返回给定数字的反双曲正弦值, 即:"><code>asinh()</code></a>, <a href="Reference/Global_Objects/Math/atanh" title="Math.atanh() 函数返回一个数值反双曲正切值, 即:"><code>atanh()</code></a>, <a href="Reference/Global_Objects/Math/hypot" title="Math.hypot() 函数返回它的所有参数的平方和的平方根,即:"><code>hypot()</code></a>, <a href="Reference/Global_Objects/Math/trunc" title="Math.trunc() 方法会将数字的小数部分去掉,只保留整数部分。"><code>trunc()</code></a>, <a href="Reference/Global_Objects/Math/sign" title="Math.sign() 函数返回一个数字的符号, 指示数字是正数,负数还是零。"><code>sign()</code></a>, <a href="Reference/Global_Objects/Math/imul" title="该函数返回两个参数的类C的32位整数乘法运算的运算结果."><code>imul()</code></a>, <a href="Reference/Global_Objects/Math/fround" title="Math.fround() 可以将任意的数字转换为离它最近的单精度浮点数形式的数字。"><code>fround()</code></a>, <a href="Reference/Global_Objects/Math/cbrt" title="Math.cbrt() 函数返回任意数字的立方根."><code>cbrt()</code></a> and <a href="Reference/Global_Objects/Math/clz32" title="Math.clz32() 函数返回一个数字在转换成 32 无符号整形数字的二进制形式后, 开头的 0 的个数, 比如 1000000 转换成 32 位无符号整形数字的二进制形式后是 00000000000011110100001001000000, 开头的 0 的个数是 12 个, 则 Math.clz32(1000000) 返回 12."><code>clz32()</code></a> added.</td>
</tr>
</tbody>
</table>
<h2 id="Browser_compatibility" name="Browser_compatibility" style="margin: 0px 0px 20px; padding: 0px; border: 0px; word-wrap: break-word; font-family: 'Open Sans', Arial, sans-serif; line-height: 1; font-size: 2.14285714285714rem; letter-spacing: -1px; color: rgb(77, 78, 83); background-color: rgb(255, 255, 255);">浏览器兼容性</h2>
<div style="margin: 0px; padding: 0px; border: 0px; color: rgb(77, 78, 83); font-family: 'Open Sans', Arial, sans-serif; font-size: 14px; line-height: 21px; background-color: rgb(255, 255, 255);"><div class="blockIndicator warning"><strong><a class="external" href="https://github.com/mdn/browser-compat-data" rel="noopener">We're converting our compatibility data into a machine-readable JSON format</a></strong>.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
<strong><a class="new" href="/zh-CN/docs/MDN/Contribute/Structures/Compatibility_tables" rel="nofollow">Find out how you can help!</a></strong></div>
<div class="htab">
<a id="AutoCompatibilityTable" name="AutoCompatibilityTable"></a>
<ul>
<li class="selected"><a>Desktop</a></li>
<li><a>Mobile</a></li>
</ul>
</div></div>
<div id="compat-desktop" style="margin: 0px; padding: 0px; border: 0px; color: rgb(77, 78, 83); font-family: 'Open Sans', Arial, sans-serif; font-size: 14px; line-height: 21px; background-color: rgb(255, 255, 255);">
<table class="compat-table" style="border-collapse: collapse; border: 1px solid transparent; margin: 0px; padding: 0px;">
<tbody>
<tr style="margin: 0px; padding: 0px; border: 0px;">
<th style="margin: 0px; padding: 2px 4px 8px; border: 1px solid rgba(212, 221, 228, 0); font-style: inherit; font-weight: 200; font-family: 'Open Sans Light', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 16px; background: 0px 0px;">Feature</th>
<th style="margin: 0px; padding: 2px 4px 8px; border: 1px solid rgba(212, 221, 228, 0); font-style: inherit; font-weight: 200; font-family: 'Open Sans Light', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 16px; background: 0px 0px;">Chrome</th>
<th style="margin: 0px; padding: 2px 4px 8px; border: 1px solid rgba(212, 221, 228, 0); font-style: inherit; font-weight: 200; font-family: 'Open Sans Light', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 16px; background: 0px 0px;">Firefox (Gecko)</th>
<th style="margin: 0px; padding: 2px 4px 8px; border: 1px solid rgba(212, 221, 228, 0); font-style: inherit; font-weight: 200; font-family: 'Open Sans Light', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 16px; background: 0px 0px;">Internet Explorer</th>
<th style="margin: 0px; padding: 2px 4px 8px; border: 1px solid rgba(212, 221, 228, 0); font-style: inherit; font-weight: 200; font-family: 'Open Sans Light', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 16px; background: 0px 0px;">Opera</th>
<th style="margin: 0px; padding: 2px 4px 8px; border: 1px solid rgba(212, 221, 228, 0); font-style: inherit; font-weight: 200; font-family: 'Open Sans Light', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 16px; background: 0px 0px;">Safari</th>
</tr>
<tr style="margin: 0px; padding: 0px; border: 0px;">
<td style="margin: 0px; padding: 5px; border: 1px solid rgba(212, 221, 228, 0.247059); font-size: 12px; vertical-align: top; word-wrap: break-word; background-clip: initial;">Basic support</td>
<td style="margin: 0px; padding: 5px; border: 1px solid rgba(212, 221, 228, 0.247059); font-size: 12px; vertical-align: top; word-wrap: break-word; background-clip: initial;"><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td style="margin: 0px; padding: 5px; border: 1px solid rgba(212, 221, 228, 0.247059); font-size: 12px; vertical-align: top; word-wrap: break-word; background-clip: initial;"><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td style="margin: 0px; padding: 5px; border: 1px solid rgba(212, 221, 228, 0.247059); font-size: 12px; vertical-align: top; word-wrap: break-word; background-clip: initial;"><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td style="margin: 0px; padding: 5px; border: 1px solid rgba(212, 221, 228, 0.247059); font-size: 12px; vertical-align: top; word-wrap: break-word; background-clip: initial;"><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td style="margin: 0px; padding: 5px; border: 1px solid rgba(212, 221, 228, 0.247059); font-size: 12px; vertical-align: top; word-wrap: break-word; background-clip: initial;"><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
</tr>
</tbody>
</table>
</div>
<div id="compat-mobile" style="margin: 0px; padding: 0px; border: 0px; color: rgb(77, 78, 83); font-family: 'Open Sans', Arial, sans-serif; font-size: 14px; line-height: 21px; background-color: rgb(255, 255, 255);">
<table class="compat-table" style="border-collapse: collapse; border: 1px solid transparent; margin: 0px; padding: 0px;">
<tbody>
<tr style="margin: 0px; padding: 0px; border: 0px;">
<th style="margin: 0px; padding: 2px 4px 8px; border: 1px solid rgba(212, 221, 228, 0); font-style: inherit; font-weight: 200; font-family: 'Open Sans Light', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 16px; background: 0px 0px;">Feature</th>
<th style="margin: 0px; padding: 2px 4px 8px; border: 1px solid rgba(212, 221, 228, 0); font-style: inherit; font-weight: 200; font-family: 'Open Sans Light', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 16px; background: 0px 0px;">Android</th>
<th style="margin: 0px; padding: 2px 4px 8px; border: 1px solid rgba(212, 221, 228, 0); font-style: inherit; font-weight: 200; font-family: 'Open Sans Light', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 16px; background: 0px 0px;">Chrome for Android</th>
<th style="margin: 0px; padding: 2px 4px 8px; border: 1px solid rgba(212, 221, 228, 0); font-style: inherit; font-weight: 200; font-family: 'Open Sans Light', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 16px; background: 0px 0px;">Firefox Mobile (Gecko)</th>
<th style="margin: 0px; padding: 2px 4px 8px; border: 1px solid rgba(212, 221, 228, 0); font-style: inherit; font-weight: 200; font-family: 'Open Sans Light', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 16px; background: 0px 0px;">IE Mobile</th>
<th style="margin: 0px; padding: 2px 4px 8px; border: 1px solid rgba(212, 221, 228, 0); font-style: inherit; font-weight: 200; font-family: 'Open Sans Light', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 16px; background: 0px 0px;">Opera Mobile</th>
<th style="margin: 0px; padding: 2px 4px 8px; border: 1px solid rgba(212, 221, 228, 0); font-style: inherit; font-weight: 200; font-family: 'Open Sans Light', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 16px; background: 0px 0px;">Safari Mobile</th>
</tr>
<tr style="margin: 0px; padding: 0px; border: 0px;">
<td style="margin: 0px; padding: 5px; border: 1px solid rgba(212, 221, 228, 0.247059); font-size: 12px; vertical-align: top; word-wrap: break-word; background-clip: initial;">Basic support</td>
<td style="margin: 0px; padding: 5px; border: 1px solid rgba(212, 221, 228, 0.247059); font-size: 12px; vertical-align: top; word-wrap: break-word; background-clip: initial;"><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td style="margin: 0px; padding: 5px; border: 1px solid rgba(212, 221, 228, 0.247059); font-size: 12px; vertical-align: top; word-wrap: break-word; background-clip: initial;"><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td style="margin: 0px; padding: 5px; border: 1px solid rgba(212, 221, 228, 0.247059); font-size: 12px; vertical-align: top; word-wrap: break-word; background-clip: initial;"><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td style="margin: 0px; padding: 5px; border: 1px solid rgba(212, 221, 228, 0.247059); font-size: 12px; vertical-align: top; word-wrap: break-word; background-clip: initial;"><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td style="margin: 0px; padding: 5px; border: 1px solid rgba(212, 221, 228, 0.247059); font-size: 12px; vertical-align: top; word-wrap: break-word; background-clip: initial;"><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td style="margin: 0px; padding: 5px; border: 1px solid rgba(212, 221, 228, 0.247059); font-size: 12px; vertical-align: top; word-wrap: break-word; background-clip: initial;"><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
</tr>
</tbody>
</table>
</div>
<h2 id="See_also" name="See_also" style="margin: 0px 0px 20px; padding: 0px; border: 0px; word-wrap: break-word; font-family: 'Open Sans', Arial, sans-serif; line-height: 1; font-size: 2.14285714285714rem; letter-spacing: -1px; color: rgb(77, 78, 83); background-color: rgb(255, 255, 255);">参见</h2>
<ul style="margin: 0px 0px 24px; padding: 0px 0px 0px 40px; border: 0px; color: rgb(77, 78, 83); font-family: 'Open Sans', Arial, sans-serif; font-size: 14px; line-height: 21px; background-color: rgb(255, 255, 255);">
<li style="margin: 0px 0px 6px; padding: 0px; border: 0px;"><a href="Reference/Global_Objects/Number" title="JavaScript 的 Number 对象是经过封装的能让你处理数字值的对象。Number 对象由 Number() 构造器创建。"><code>Number</code></a></li>
</ul>
<div style="margin: 0px; padding: 0px; border: 0px; color: rgb(77, 78, 83); font-family: 'Open Sans', Arial, sans-serif; font-size: 14px; line-height: 21px; background-color: rgb(255, 255, 255);"> </div>
<dl>
</dl>
</article>