The Number.MIN_SAFE_INTEGER static data property represents the minimum safe integer in JavaScript, or -(253 - 1).
To represent integers smaller than this, consider using BigInt.
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2015.
The Number.MIN_SAFE_INTEGER static data property represents the minimum safe integer in JavaScript, or -(253 - 1).
To represent integers smaller than this, consider using BigInt.
const x = Number.MIN_SAFE_INTEGER - 1; const y = Number.MIN_SAFE_INTEGER - 2; console.log(Number.MIN_SAFE_INTEGER); // Expected output: -9007199254740991 console.log(x); // Expected output: -9007199254740992 console.log(x === y); // Expected output: true
-9007199254740991 (-9,007,199,254,740,991, or about -9 quadrillion).
Property attributes of Number.MIN_SAFE_INTEGER
| |
|---|---|
| Writable | no |
| Enumerable | no |
| Configurable | no |
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.
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.
Number.MIN_SAFE_INTEGER; // -9007199254740991 -(2 ** 53 - 1); // -9007199254740991
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | Deno | Node.js | |
MIN_SAFE_INTEGER |
34 | 12 | 31 | 21 | 9 | 34 | 31 | 21 | 9 | 2.0 | 37 | 1.0 | 0.12.0 |
© 2005–2024 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_SAFE_INTEGER