Example 1 — Read Number.MIN_SAFE_INTEGER
Print the smallest exact integer Number.
Number.MIN_SAFE_INTEGER;
// -9007199254740991 How It Works
Same as -(2 ** 53 - 1). Prefer the named constant in readable code.
Number.MIN_SAFE_INTEGER is a static data property on Number (same API as MDN Number.MIN_SAFE_INTEGER). It is the smallest integer a JavaScript Number can represent exactly — −(253 − 1) (-9007199254740991). Below it, use BigInt. This tutorial covers its value, the famous −1 === −2 trap, how it mirrors MAX_SAFE_INTEGER, five examples, and try-it labs.
Static property
−(253−1)
Exact integers
Use BigInt
No
Everywhere
Safe integers form a symmetric window around zero. The positive edge is Number.MAX_SAFE_INTEGER; the negative edge is Number.MIN_SAFE_INTEGER — exactly -Number.MAX_SAFE_INTEGER.
Inside that window, every integer is exact and comparable. Step one past the negative bound and neighbors start collapsing — just like on the positive side.
Static properties belong to Number itself. Always write Number.MIN_SAFE_INTEGER. There is no (5).MIN_SAFE_INTEGER, and you do not call it like a function.
This page is part of JavaScript Number Properties. Related tools include Number.isSafeInteger(), Number.MAX_SAFE_INTEGER, and Number.MIN_VALUE (a different concept — smallest positive Number).
MIN_SAFE_INTEGER Property“Safe” means the integer can be stored exactly and compared correctly. The safe range is Number.MIN_SAFE_INTEGER … Number.MAX_SAFE_INTEGER inclusive.
-9007199254740991 (−(253 − 1)).-Number.MAX_SAFE_INTEGER.General form of the static property Number.MIN_SAFE_INTEGER:
Number.MIN_SAFE_INTEGER -9007199254740991 (−(253 − 1)).
| Attribute | Value |
|---|---|
| Writable | false |
| Enumerable | false |
| Configurable | false |
Number.MIN_SAFE_INTEGER; // -9007199254740991
Number.MIN_SAFE_INTEGER === -(2 ** 53 - 1); // true
Number.MIN_SAFE_INTEGER === -Number.MAX_SAFE_INTEGER; // true
Number.isSafeInteger(Number.MIN_SAFE_INTEGER); // true
Number.isSafeInteger(Number.MIN_SAFE_INTEGER - 1); // false
// Prefer BigInt past the safe range:
-9007199254740993n; // exact | Goal | Code |
|---|---|
| Smallest exact integer | Number.MIN_SAFE_INTEGER |
| Largest exact integer | Number.MAX_SAFE_INTEGER |
| Test a candidate | Number.isSafeInteger(n) |
| More-negative exact ints | BigInt / -123n |
| Most negative finite float | -Number.MAX_VALUE (not exact ints) |
| Smallest positive Number | Number.MIN_VALUE (different!) |
Four facts to remember about Number.MIN_SAFE_INTEGER.
staticProperty on Number
-(2**53-1)-9007199254740991
-MAXEquals -MAX_SAFE_INTEGER
noRead-only constant
MIN_SAFE_INTEGER vs MIN_VALUE vs -MAX_VALUEMIN_SAFE_INTEGER | MIN_VALUE | -MAX_VALUE | |
|---|---|---|---|
| Approx. size | ~-9.0e15 | 5e-324 | ~-1.8e308 |
| Sign | Negative | Positive | Negative |
| Meaning | Smallest exact int | Closest to 0+ | Most negative finite |
| Exact integers? | Yes (at bound) | N/A (tiny float) | No (sparse) |
Examples follow MDN Number.MIN_SAFE_INTEGER patterns. Use View Output or Try It Yourself for each case.
Read the constant and see why “safe” matters on the negative side.
Number.MIN_SAFE_INTEGERPrint the smallest exact integer Number.
Number.MIN_SAFE_INTEGER;
// -9007199254740991 Same as -(2 ** 53 - 1). Prefer the named constant in readable code.
−1 === −2 TrapPast the safe limit, consecutive integers are no longer distinct.
const x = Number.MIN_SAFE_INTEGER - 1;
const y = Number.MIN_SAFE_INTEGER - 2;
Number.MIN_SAFE_INTEGER; // -9007199254740991
x; // -9007199254740992
x === y; // true (!) Both x and y round to the same float — the negative twin of the MAX_SAFE_INTEGER trap.
Checks, symmetry with MAX, and naming mix-ups.
isSafeInteger()Test whether a value is still inside the exact-integer window.
Number.isSafeInteger(Number.MIN_SAFE_INTEGER); // true
Number.isSafeInteger(Number.MIN_SAFE_INTEGER - 1); // false See the full isSafeInteger() tutorial for coercion rules and edge cases.
MAX_SAFE_INTEGERThe two constants are exact opposites.
Number.MIN_SAFE_INTEGER === -Number.MAX_SAFE_INTEGER; // true
Number.MAX_SAFE_INTEGER; // 9007199254740991
Number.MIN_SAFE_INTEGER; // -9007199254740991 One 53-bit significand defines both edges of the safe integer window.
MIN_VALUEAvoid the common naming mix-up.
Number.MIN_SAFE_INTEGER; // -9007199254740991 (exact int floor)
Number.MIN_VALUE; // 5e-324 (tiny positive)
Number.MIN_SAFE_INTEGER < 0; // true
Number.MIN_VALUE > 0; // true MIN_VALUE is about near-zero positives. MIN_SAFE_INTEGER is about exact negative integers.
Number.isSafeInteger(n) before trusting integer math.+1 === +2 trap.Doubles store about 53 bits of precision for the fraction.
Every integer in the safe window has a unique Number encoding.
Some more-negative integers cannot be represented; neighbors collapse.
Stay in range, or move to BigInt / string IDs.
Number.MIN_SAFE_INTEGER only.Number.MIN_SAFE_INTEGER() — it is not a function.-Number.MAX_SAFE_INTEGER.-Number.MAX_VALUE (magnitude, not exact ints).Number.MIN_SAFE_INTEGER is Baseline Widely available — part of ES2015 and supported in every modern browser and Node.js.
Safe for production everywhere. Use it as the named floor for exact Number integers.
Bottom line: Stay within MIN_SAFE_INTEGER … MAX_SAFE_INTEGER for exact Number integers. Use BigInt outside that window.
Number.MIN_SAFE_INTEGER is the static constant for the smallest integer a JavaScript Number can represent exactly. Below that point, prefer BigInt when every integer must stay distinct.
Continue with MAX_SAFE_INTEGER, isSafeInteger(), MIN_VALUE, or the Number properties hub.
Number.MIN_SAFE_INTEGER on the constructorNumber.isSafeInteger(n)-MAX_SAFE_INTEGER(5).MIN_SAFE_INTEGER or call it as a functionNumber.MIN_VALUE-MAX_VALUE integers are exact===Number.MIN_SAFE_INTEGERStatic floor for exact Number integers.
static
API-(2**53-1)
Constant-1 === -2
PitfallBigInt
Nextno
ReadonlyThe safe integer range is perfectly symmetric: [MIN_SAFE_INTEGER, MAX_SAFE_INTEGER] = [−(253−1), 253−1]. Zero sits in the middle, and both edges share the same 53-bit precision story.
Return to the hub for static Number constants.
8 people found this page helpful