JavaScript .MIN_SAFE_INTEGER

ptoth's avatar
Published Aug 8, 2025
Contribute to Docs

In JavaScript, the .MIN_SAFE_INTEGER property is a static constant that represents the smallest safe integer in JavaScript: -(2^53 - 1) or -9007199254740991. JavaScript uses the IEEE-754 double-precision format for all numbers, meaning not all integers can be represented exactly. A safe integer is one that:

  • Can be precisely represented
  • Doesn’t lose precision during arithmetic
  • Can be accurately compared

Since JavaScript is dynamically typed, all numbers fall under the Number type and are treated as floating-point values. .MIN_SAFE_INTEGER isn’t tied to any variable as it’s accessed directly via .MIN_SAFE_INTEGER. Values smaller than this limit may suffer from rounding errors or incorrect comparisons due to floating-point precision limits.

  • Front-end engineers work closely with designers to make websites beautiful, functional, and fast.
    • Includes 34 Courses
    • With Professional Certification
    • Beginner Friendly.
      115 hours
  • Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.
    • Beginner Friendly.
      15 hours

Syntax

Number.MIN_SAFE_INTEGER

Parameters:

.MIN_SAFE_INTEGER is a static property of the Number object. It’s accessed directly without calling a function or passing arguments.

Return value:

It returns a number: -9007199254740991. This is the smallest integer JavaScript can represent safely without precision loss using the Number type (IEEE-754 double-precision).

Example

In this example, subtracting beyond the minimum safe integer leads to precision loss, causing distinct values to compare as equal:

console.log(Number.MIN_SAFE_INTEGER);
const a = Number.MIN_SAFE_INTEGER - 1;
const b = Number.MIN_SAFE_INTEGER - 2;
console.log(a === b);

The output of this code is:

-9007199254740991
true

This demonstrates what happens when values go below the minimum safe integer. Although a and b should be distinct (-9007199254740992 and -9007199254740993), both are stored as the same value due to floating-point precision limits. So, a === b returns true, even though they are not mathematically equal.

Codebyte Example

In this codebyte example, .isSafeInteger() is used to check if a value just below the minimum safe integer is still considered safe:

Code
Output
Loading...

All contributors

Contribute to Docs

Learn JavaScript on Codecademy

  • Front-end engineers work closely with designers to make websites beautiful, functional, and fast.
    • Includes 34 Courses
    • With Professional Certification
    • Beginner Friendly.
      115 hours
  • Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.
    • Beginner Friendly.
      15 hours