diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/javascript/reference/global_objects/number/negative_infinity | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/number/negative_infinity')
-rw-r--r-- | files/zh-cn/web/javascript/reference/global_objects/number/negative_infinity/index.html | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/number/negative_infinity/index.html b/files/zh-cn/web/javascript/reference/global_objects/number/negative_infinity/index.html new file mode 100644 index 0000000000..6649246cf5 --- /dev/null +++ b/files/zh-cn/web/javascript/reference/global_objects/number/negative_infinity/index.html @@ -0,0 +1,112 @@ +--- +title: Number.NEGATIVE_INFINITY +slug: Web/JavaScript/Reference/Global_Objects/Number/NEGATIVE_INFINITY +translation_of: Web/JavaScript/Reference/Global_Objects/Number/NEGATIVE_INFINITY +--- +<div> + {{JSRef("Global_Objects", "Number")}}</div> +<h2 id="Summary" name="Summary">概述</h2> +<p><code><strong>Number.NEGATIVE_INFINITY</strong></code> 属性表示负无穷大。</p> +<p>不用创建一个 {{jsxref("Global_Objects/Number", "Number")}} 实例,使用 <code>Number.NEGATIVE_INFINITY</code> 来访问该静态属性。</p> +<p>{{js_property_attributes(0,0,0)}}</p> +<h2 id="Description" name="Description">描述</h2> +<p><code>Number.NEGATIVE_INFINITY</code> 的值和全局对象的 {{jsxref("Global_Objects/Infinity", "Infinity")}} 属性的负值相同。</p> +<p>该值的行为同数学上的无穷大(infinity)有一点儿不同:</p> +<ul> + <li>任何正值,包括 <code>POSITIVE_INFINITY,</code>乘以 <code>NEGATIVE_INFINITY</code> 为 <code>NEGATIVE_INFINITY</code>。</li> + <li>任何负值,包括 <code>NEGATIVE_INFINITY</code>,乘以 <code>NEGATIVE_INFINITY</code> 为 <code>POSITIVE_INFINITY</code>。</li> + <li>0 乘以 <code>NEGATIVE_INFINITY</code> 为 <code>NaN</code>.</li> + <li>NaN 乘以 <code>NEGATIVE_INFINITY</code> 为<code> NaN</code>.</li> + <li><code>NEGATIVE_INFINITY</code> 除以任何负值(除了 <code>NEGATIVE_INFINITY)</code>为 <code>POSITIVE_INFINITY</code>。</li> + <li><code>NEGATIVE_INFINITY</code> 除以任何正值(除了 <code>POSITIVE_INFINITY</code>)为 <code>NEGATIVE_INFINITY</code>。</li> + <li><code>NEGATIVE_INFINITY</code> 除以 <code>NEGATIVE_INFINITY</code> 或 <code>POSITIVE_INFINITY</code> 是 <code>NaN</code>。</li> + <li>任何数除以 <code>NEGATIVE_INFINITY</code> 为 0。</li> +</ul> +<p>为了成功返回一个有限值,你可能会使用 <code>Number.NEGATIVE_INFINITY</code> 属性来判断是否显示一个条件错误 。然而 {{jsxref("Global_Objects/isFinite", "isFinite")}} 方法更适合这种情况。</p> +<h2 id="Example" name="Example">示例</h2> +<p>下例中,赋值给变量 <code>smallNumber</code> 一个明显小于 JavaScript 中的最小值的值。当 <code>if</code> 语句执行时,<code>smallNumber</code> 值为 "<code>-Infinity</code>",因此在继续执行代码前,<code>smallNumber</code> 被设为一个更容易管理的值。</p> +<pre class="brush:js">var smallNumber = (-Number.MAX_VALUE) * 2 + +if (smallNumber == Number.NEGATIVE_INFINITY) { + smallNumber = returnFinite(); +} +</pre> +<h2 id="规范">规范</h2> +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + <tr> + <td>ECMAScript 1st Edition. Implemented in JavaScript 1.1</td> + <td>Standard</td> + <td>Initial definition.</td> + </tr> + <tr> + <td>{{SpecName('ES5.1', '#sec-15.7.3.5', 'Number.NEGATIVE_INFINITY')}}</td> + <td>{{Spec2('ES5.1')}}</td> + <td> </td> + </tr> + <tr> + <td>{{SpecName('ES6', '#sec-number.negative_infinity', 'Number.NEGATIVE_INFINITY')}}</td> + <td>{{Spec2('ES6')}}</td> + <td> </td> + </tr> + </tbody> +</table> +<h2 id="浏览器规范">浏览器规范</h2> +<p>{{ CompatibilityTable() }}</p> +<div id="compat-desktop"> + <table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Chrome</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{ CompatVersionUnknown() }}</td> + <td>{{ CompatVersionUnknown() }}</td> + <td>{{ CompatVersionUnknown() }}</td> + <td>{{ CompatVersionUnknown() }}</td> + <td>{{ CompatVersionUnknown() }}</td> + </tr> + </tbody> + </table> +</div> +<div id="compat-mobile"> + <table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Android</th> + <th>Chrome for Android</th> + <th>Firefox Mobile (Gecko)</th> + <th>IE Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{ CompatVersionUnknown() }}</td> + <td>{{ CompatVersionUnknown() }}</td> + <td>{{ CompatVersionUnknown() }}</td> + <td>{{ CompatVersionUnknown() }}</td> + <td>{{ CompatVersionUnknown() }}</td> + <td>{{ CompatVersionUnknown() }}</td> + </tr> + </tbody> + </table> +</div> +<h2 id="See_also" name="See_also">相关链接</h2> +<ul> + <li>{{jsxref("Number.POSITIVE_INFINITY")}}</li> + <li>{{jsxref("Global_Objects/Infinity", "Infinity")}}</li> + <li>{{jsxref("Global_Objects/isFinite", "isFinite")}}</li> +</ul> |