语法高亮,滚动条美化,设置页面调整

This commit is contained in:
fofolee
2019-04-19 02:41:09 +08:00
parent 1e8f76c000
commit 359d29ee0b
1590 changed files with 12328 additions and 11441 deletions

View File

@@ -2,7 +2,7 @@
<p></p><p></p>
<p><code><strong>Math.round()</strong></code> 函数返回一个数字四舍五入后最接近的整数。</p>
<h2 id="Syntax" name="Syntax">语法</h2>
<pre class="syntaxbox"><code>Math.round(<em>x</em>) </code></pre>
<pre><code class="language-javascript"><code>Math.round(<em>x</em>) </code></code></pre>
<h3 id="Parameters" name="Parameters">参数</h3>
<dl>
<dt><code>x</code></dt>
@@ -16,13 +16,13 @@
<p>如果参数的小数部分大于 0.5,则舍入到相邻的绝对值更大的整数。 如果参数的小数部分小于 0.5则舍入到相邻的绝对值更小的整数。如果参数的小数部分恰好等于0.5,则舍入到相邻的在正无穷(+∞)方向上的整数。<strong>注意,与很多其他语言中的<code>round()函数</code>不同,<code>Math.round()并不总是舍入到远离0的方向尤其是在负数的小数部分恰好等于0.5的情况下)。</code></strong></p>
<p>因为 <code>round()</code> 是 <code>Math</code> 的静态方法,你应该直接使用 <code>Math.round()</code>,而不是作为你创建的 <code>Math</code> 对象的一个实例方法来使用(<code>Math</code>没有构造函数)。</p>
<h2 id="Examples" name="Examples">示例</h2>
<pre class="brush:js">x = Math.round(20.49); //20
<pre><code class="language-js">x = Math.round(20.49); //20
x = Math.round(20.5); //21
x = Math.round(-20.5); //-20
x = Math.round(-20.51); //-21
</pre>
</code></pre>
<h3 id="Example:_Decimal_rounding" name="Example:_Decimal_rounding" style="line-height: 24px;">小数舍入</h3>
<pre class="brush: js">// 闭包
<pre><code class="language-javascript">// 闭包
(function(){
  /**
@@ -93,16 +93,16 @@ Math.ceil10(55.51, -1); // 55.6
Math.ceil10(51, 1); // 60
Math.ceil10(-55.59, -1); // -55.5
Math.ceil10(-59, 1); // -50
</pre>
</code></pre>
<p>或:</p>
<pre class="brush: js">function round(number, precision) {
<pre><code class="language-javascript">function round(number, precision) {
    return Math.round(+number + 'e' + precision) / Math.pow(10, precision);
  //same as:
//return Number(Math.round(+number + 'e' + precision) + 'e-' + precision);
}
round(1.005, 2); //1.01
</pre>
</code></pre>
<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 0px; background: 0px 0px;"> </div>
<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 19px; background: 0px 0px;"> </div>
<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 38px; background: 0px 0px;"> </div>