Number.MIN_SAFE_INTEGER

Number.MIN_SAFE_INTEGER 静态数据属性表示 JavaScript 中的最小安全整数,即 -(253 - 1)。

¥The Number.MIN_SAFE_INTEGER static data property represents the minimum safe integer in JavaScript, or -(253 - 1).

要表示小于此的整数,请考虑使用 BigInt

¥To represent integers smaller than this, consider using BigInt.

Try it

¥Value

-9007199254740991(-9,007,199,254,740,991,或约-9 千万亿)。

¥-9007199254740991 (-9,007,199,254,740,991, or about -9 quadrillion).

Property attributes of Number.MIN_SAFE_INTEGER
Writable no
Enumerable no
Configurable no

描述

¥Description

双精度浮点格式 只有 52 位来表示 mantissa,因此它只能安全地表示 -(253 – 1) 和 253 – 1 之间的整数。在这种情况下,安全是指准确表示整数并正确比较它们的能力。例如,Number.MIN_SAFE_INTEGER - 1 === Number.MIN_SAFE_INTEGER - 2 将计算为 true,这在数学上是不正确的。请参阅 Number.isSafeInteger() 了解更多信息。

¥Double precision floating point format only has 52 bits to represent the mantissa, so it can only safely represent integers between -(253 – 1) and 253 – 1. Safe in this context refers to the ability to represent integers exactly and to correctly compare them. For example, Number.MIN_SAFE_INTEGER - 1 === Number.MIN_SAFE_INTEGER - 2 will evaluate to true, which is mathematically incorrect. See Number.isSafeInteger() for more information.

由于 MIN_SAFE_INTEGERNumber 的静态属性,因此你始终将其用作 Number.MIN_SAFE_INTEGER,而不是作为数字值的属性。

¥Because MIN_SAFE_INTEGER is a static property of Number, you always use it as Number.MIN_SAFE_INTEGER, rather than as a property of a number value.

示例

¥Examples

使用 MIN_SAFE_INTEGER

¥Using MIN_SAFE_INTEGER

js
Number.MIN_SAFE_INTEGER; // -9007199254740991
-(2 ** 53 - 1); // -9007199254740991

规范

Specification
ECMAScript Language Specification
# sec-number.min_safe_integer

¥Specifications

浏览器兼容性

BCD tables only load in the browser

¥Browser compatibility

也可以看看