blob: 17f185892785c777155dedabac146ec21c4b4cda (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
---
title: Number.MIN_SAFE_INTEGER
slug: Web/JavaScript/Reference/Global_Objects/Number/MIN_SAFE_INTEGER
translation_of: Web/JavaScript/Reference/Global_Objects/Number/MIN_SAFE_INTEGER
---
<div>{{JSRef}}</div>
<p><strong><code>Number.MIN_SAFE_INTEGER</code></strong> 代表在 JavaScript中最小的安全的integer型数字 (<code>-(2^53 - 1)</code>).</p>
<div>{{js_property_attributes(0, 0, 0)}}</div>
<h2 id="描述">描述</h2>
<p><code>MIN_SAFE_INTEGER</code> 的值是<code>-9007199254740991</code>. 形成这个数字的原因是 JavaScript 在 <a href="http://en.wikipedia.org/wiki/IEEE_floating_point">IEEE 754</a>中使用<a href="http://en.wikipedia.org/wiki/Double_precision_floating-point_format">double-precision floating-point format numbers</a> 作为规定。在这个规定中能安全的表示数字的范围在<code>-(2^53 - 1)</code> 到 <code>2^53 - 1</code>之间.</p>
<p><code>由于MIN_SAFE_INTEGER</code> 是{{jsxref("Number")}}的一个静态属性,你可以直接使用<code>Number.MIN_SAFE_INTEGER</code>, 而不是自己去创建一个{{jsxref("Number")}}的属性。 </p>
<h2 id="示例">示例</h2>
<pre class="brush: js">Number.MIN_SAFE_INTEGER // -9007199254740991
-(Math.pow(2, 53) - 1) // -9007199254740991
</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>{{SpecName('ES6', '#sec-number.min_safe_integer', 'Number.MIN_SAFE_INTEGER')}}</td>
<td>{{Spec2('ES6')}}</td>
<td>Initial definition.</td>
</tr>
<tr>
<td>{{SpecName('ESDraft', '#sec-number.min_safe_integer', 'Number.MIN_SAFE_INTEGER')}}</td>
<td>{{Spec2('ESDraft')}}</td>
<td></td>
</tr>
</tbody>
</table>
<h2 id="浏览器支持">浏览器支持</h2>
{{Compat("javascript.builtins.Number.MIN_SAFE_INTEGER")}}
<h2 id="参阅">参阅</h2>
<ul>
<li>{{jsxref("Number.MAX_SAFE_INTEGER")}}</li>
<li>{{jsxref("Number.isSafeInteger()")}}</li>
</ul>
|