To a precision of 1 decimal digits, the maximum number you can work with is 562949953421311.

To a precision of 2 decimal digits, it's 70368744177663. Interestingly, the first number is equal to:

(Number.MAX_SAFE_INTEGER + 1) / 16 - 1

And the second number is equal to:

(Number.MAX_SAFE_INTEGER + 1) / 128 - 1

What we're looking for, is the maximum safe number to support a precision of d digits after the decimal point. By "support" I mean "can reliably do basic arithmetic".

For example, we know that Number.MAX_SAFE_INTEGER (aka 2**53-1) is not safe, because basic arithmetic is broken:

Number.MAX_SAFE_INTEGER - 0.1 === Number.MAX_SAFE_INTEGER
>>> true // unsafe

And we know that 0 is safe, since:

0 + 0.1 === 0
>>> false // safe

BTW, 0 is reliable as far as 1e-323 (including):

0 + 1e-323 === 0
>>> false // safe

0 + 1e-324 === 0
>>> true // unsafe

I binary-searched between 0 and Number.MAX_SAFE_INTEGER for the biggest number that answers that definition, and came up with these numbers.

Here's the code (pass any other number to findMaxSafeFloat() at the end of snippet)

/**Returns whether basic arithmetic breaks between n and n+1, to a precision of `digits` after the decimal point*/
function isUnsafe(n, digits) {
  // digits = 1 loops 10 times with 0.1 increases.
  // digits = 2 means 100 steps of 0.01, and so on.
  let prev = n;
  for (let i = 10 ** -digits; i < 1; i += 10 ** -digits) {
    if (n + i === prev) { // eg 10.2 === 10.1
      return true;
    }
    prev = n + i;
  }
  return false;


}

/**Binary search between 0 and Number.MAX_SAFE_INTEGER (2**53 - 1) for the biggest number that is safe to the `digits` level of precision.
 * digits=9 took ~30s, I wouldn't pass anything bigger.*/
function findMaxSafeFloat(digits, log = false) {
  let n = Number.MAX_SAFE_INTEGER;
  let lastSafe = 0;
  let lastUnsafe = undefined;
  while (true) {
    if (log) {
      console.table({
        '': {
          n,
          'Relative to Number.MAX_SAFE_INTEGER': `(MAX + 1) / ${(Number.MAX_SAFE_INTEGER + 1) / (n + 1)} - 1`,
          lastSafe,
          lastUnsafe,
          'lastUnsafe - lastSafe': lastUnsafe - lastSafe
        }
      });
    }
    if (isUnsafe(n, digits)) {
      lastUnsafe = n;
    } else { // safe
      if (lastSafe + 1 === n) { // Closed in as far as possible
        console.log(`\n\nMax safe number to a precision of ${digits} digits after the decimal point: ${n}\t((MAX + 1) / ${(Number.MAX_SAFE_INTEGER + 1) / (n + 1)} - 1)\n\n`);
        return n;
      } else {
        lastSafe = n;
      }
    }
    n = Math.round((lastSafe + lastUnsafe) / 2);
  }
}

console.log(findMaxSafeFloat(1));

An interesting thing I've found by lining up the safe numbers, is that the exponents don't step up in a consistent manner. Look at the table below; once in a while, the exponent increases (or decreases) by 4, and not 3. Not sure why.

| Precision | First UNsafe                | 2^53/x                   |
|-----------|-----------------------------|--------------------------|
| 1         | 562,949,953,421,312 = 2^49  | x = 16 = 2^4             |
| 2         |  70,368,744,177,664 = 2^46  | x = 128 = 2^7            |
| 3         |   8,796,093,022,208 = 2^43  | x = 1,024 = 2^10         |
| 4         |     549,755,813,888 = 2^39  | x = 16,384 = 2^14        |
| 5         |      68,719,476,736 = 2^36  | x = 131,072 = 2^17       |
| 6         |       8,589,934,592 = 2^33  | x = 1,048,576 = 2^20     |
| 7         |         536,870,912 = 2^29  | x = 16,777,216 = 2^24    |
| 8         |          67,108,864 = 2^26  | x = 134,217,728 = 2^27   |
| 9         |           8,388,608 = 2^23  | x = 1,073,741,824 = 2^30 |
Answer from giladbarnea on Stack Overflow
Top answer
1 of 4
60

To a precision of 1 decimal digits, the maximum number you can work with is 562949953421311.

To a precision of 2 decimal digits, it's 70368744177663. Interestingly, the first number is equal to:

(Number.MAX_SAFE_INTEGER + 1) / 16 - 1

And the second number is equal to:

(Number.MAX_SAFE_INTEGER + 1) / 128 - 1

What we're looking for, is the maximum safe number to support a precision of d digits after the decimal point. By "support" I mean "can reliably do basic arithmetic".

For example, we know that Number.MAX_SAFE_INTEGER (aka 2**53-1) is not safe, because basic arithmetic is broken:

Number.MAX_SAFE_INTEGER - 0.1 === Number.MAX_SAFE_INTEGER
>>> true // unsafe

And we know that 0 is safe, since:

0 + 0.1 === 0
>>> false // safe

BTW, 0 is reliable as far as 1e-323 (including):

0 + 1e-323 === 0
>>> false // safe

0 + 1e-324 === 0
>>> true // unsafe

I binary-searched between 0 and Number.MAX_SAFE_INTEGER for the biggest number that answers that definition, and came up with these numbers.

Here's the code (pass any other number to findMaxSafeFloat() at the end of snippet)

/**Returns whether basic arithmetic breaks between n and n+1, to a precision of `digits` after the decimal point*/
function isUnsafe(n, digits) {
  // digits = 1 loops 10 times with 0.1 increases.
  // digits = 2 means 100 steps of 0.01, and so on.
  let prev = n;
  for (let i = 10 ** -digits; i < 1; i += 10 ** -digits) {
    if (n + i === prev) { // eg 10.2 === 10.1
      return true;
    }
    prev = n + i;
  }
  return false;


}

/**Binary search between 0 and Number.MAX_SAFE_INTEGER (2**53 - 1) for the biggest number that is safe to the `digits` level of precision.
 * digits=9 took ~30s, I wouldn't pass anything bigger.*/
function findMaxSafeFloat(digits, log = false) {
  let n = Number.MAX_SAFE_INTEGER;
  let lastSafe = 0;
  let lastUnsafe = undefined;
  while (true) {
    if (log) {
      console.table({
        '': {
          n,
          'Relative to Number.MAX_SAFE_INTEGER': `(MAX + 1) / ${(Number.MAX_SAFE_INTEGER + 1) / (n + 1)} - 1`,
          lastSafe,
          lastUnsafe,
          'lastUnsafe - lastSafe': lastUnsafe - lastSafe
        }
      });
    }
    if (isUnsafe(n, digits)) {
      lastUnsafe = n;
    } else { // safe
      if (lastSafe + 1 === n) { // Closed in as far as possible
        console.log(`\n\nMax safe number to a precision of ${digits} digits after the decimal point: ${n}\t((MAX + 1) / ${(Number.MAX_SAFE_INTEGER + 1) / (n + 1)} - 1)\n\n`);
        return n;
      } else {
        lastSafe = n;
      }
    }
    n = Math.round((lastSafe + lastUnsafe) / 2);
  }
}

console.log(findMaxSafeFloat(1));

An interesting thing I've found by lining up the safe numbers, is that the exponents don't step up in a consistent manner. Look at the table below; once in a while, the exponent increases (or decreases) by 4, and not 3. Not sure why.

| Precision | First UNsafe                | 2^53/x                   |
|-----------|-----------------------------|--------------------------|
| 1         | 562,949,953,421,312 = 2^49  | x = 16 = 2^4             |
| 2         |  70,368,744,177,664 = 2^46  | x = 128 = 2^7            |
| 3         |   8,796,093,022,208 = 2^43  | x = 1,024 = 2^10         |
| 4         |     549,755,813,888 = 2^39  | x = 16,384 = 2^14        |
| 5         |      68,719,476,736 = 2^36  | x = 131,072 = 2^17       |
| 6         |       8,589,934,592 = 2^33  | x = 1,048,576 = 2^20     |
| 7         |         536,870,912 = 2^29  | x = 16,777,216 = 2^24    |
| 8         |          67,108,864 = 2^26  | x = 134,217,728 = 2^27   |
| 9         |           8,388,608 = 2^23  | x = 1,073,741,824 = 2^30 |
2 of 4
5

Update: My understanding about this question is: Is there a maximum floating number, between 0 and that, all floating number operation can be safely delivered.

If that is the question, short answer is: No

Actually, there is no MAX_SAFE_FLOAT in all programming language (will be very glad if there is one). Number in programming language is stored by 0 or 1 bits. As long as there is a limit for the storage (32bits, 64bits etc), numbers that can be represented is finite. However, the number of floating-number is infinite.

Consider floating-number between 0 and 0.000000001, how many numbers need to be represented? Infinite. It's impossible to let computer store infinite possibility accurately. That's why there would never be MAX_SAFE_FLOAT.

p.s. In JavaScript, all numbers are 64bit double-precision floating-number. There is no floating-number v.s. interger-number in JavaScript.

🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Number › MAX_SAFE_INTEGER
Number.MAX_SAFE_INTEGER - JavaScript | MDN
The Number.MAX_SAFE_INTEGER static data property represents the maximum safe integer in JavaScript (253 – 1). For larger integers, consider using BigInt. const x = Number.MAX_SAFE_INTEGER + 1; const y = Number.MAX_SAFE_INTEGER + 2; console.log(Number.MAX_SAFE_INTEGER); // Expected output: ...
Top answer
1 of 3
75
Fun question! So in JavaScript, every value with the "number" type is represented under the hood with a 64-bit (or "double-precision") floating point number. Floating point numbers represent a value with a combination of fractions and exponents, which allows them to represent a lot of numbers (with varying degrees of precision), but at the end of the day, the value still has to fit within 64-bits somehow. So there are limits. In this case, the highest number a 64-bit float can possibly represent happens to be 1.7976931348623157e+308 (this number is stored in the constant Number.MAX_VALUE should you ever need to reference it). Your value of 1e+309 is larger than that, so the best a 64-bit float can do is call it Infinity. Under the IEEE 754 floating-point standard (which JavaScript uses), there are some special values, like NaN and Infinity. You can basically think of NaN as "something went wrong with this number" and Infinity as "this number is bigger than I can do anything useful with". Both special values sort of infect anything they touch. The result of any math with NaN is NaN. The result of (almost) any math with Infinity is Infinity. console.log(NaN * 2); // NaN console.log(Infinity - 100); // Infinity console.log(Infinity * 0); // NaN Jumping back to those varying degrees of precision, the highest integer you can represent without losing any precision happens to be a good deal smaller than 1e+308. Since everything is actually a float under the hood, you can only get up to 253 - 1 (or 9,007,199,254,740,991) before you can't trust integer math to work right anymore (that number is stored in the constant Number.MAX_SAFE_INTEGER by the way). console.log(9007199254740991 + 10); // 9007199254741000 Now, the good news for anyone who loves big numbers, is that JavaScript recently added a new primitive type, "bigint". You can make a value a BigInt by adding an n to the end, or by calling BigInt on it. const num = 7; // <-- number const big = 7n; // <-- bigint const int = BigInt(7); // <-- bigint There are two big differences between BigInts and vanilla numbers. They are integers, not floating point. This means you can't represent fractions, but you also never lose precision. They are variable-bit. They start as 64-bit, but if the value gets to large, more bits are added. So with BigInt, we can represent big numbers. let x = 10n ** 309n; // e-notation not supported with BigInt console.log(x); // 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000n And we can safely do big integer math. console.log(9007199254740991n + 10n); // 9007199254741001n But any decimal places just end up getting dropped. console.log(5n / 2n); // 2n
2 of 3
9
JavaScript uses double-precision floating point values to store numbers. The highest number you can store in this format is 1.7976931348623157e+308 or 2^1024. Anything higher than that is rounded to Infinity, as part of the floating point spec.
🌐
W3Schools
w3schools.com › jsref › jsref_max_value.asp
JavaScript MAX_VALUE Property
Number.MAX_VALUE returns the largest number possible in JavaScript.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-number-max_value-property
JavaScript Number.MAX_VALUE Property - GeeksforGeeks
August 5, 2025 - Number.MAX_VALUE represents the biggest possible numeric value of a positive number that can be represented in JavaScript. It is the maximum possible positive number representable in JavaScript within float precision.
🌐
JavaScript in Plain English
javascript.plainenglish.io › going-big-with-javascript-numbers-71616cac8e44
Going BIG with JavaScript: Numbers | by Casey Gibson | JavaScript in Plain English
February 4, 2020 - This format stores numbers in 64 bits, where the number (the fraction) is stored in bits 0 to 51, the exponent in bits 52 to 62, and the sign in bit 63 · What does this mean practically? In JavaScript, the largest possible number that can be stored is 1.7976931348623157e+308, or using ...
🌐
Dirask
dirask.com › posts › JavaScript-max-floating-point-number-value-pOJOZD
JavaScript - max floating-point number value
In JavaScript, max floating-point number value can be achieved using Number.MAX_VALUE what is equal to 1.7976931348623157e+308 (what is equivalent for max doubl...
Find elsewhere
🌐
Math.js
mathjs.org › docs › datatypes › numbers.html
math.js | an extensive math library for JavaScript and Node.js
abs(a-b) <= max(relTol * max(abs(a), abs(b)), absTol) ... relTol is the relative tolerance between x and y and absTol the absolute tolerance. Relative tolerance and absolute tolerance are configurable and are 1e-12 and 1e-15 respectively by default. See Configuration. DBL_EPSILON is the minimum positive floating point number such that 1.0 + DBL_EPSILON !== 1.0.
🌐
W3Schools
w3schools.com › js › js_numbers.asp
JavaScript Numbers
Javascript numbers are always double (64-bit floating point). Integers (numbers without a period or exponent notation) are accurate up to 15 digits. let x = 999999999999999; // x will be 999999999999999 let y = 9999999999999999; // y will be ...
🌐
Shareup
shareup.app › blog › there-is-a-maximum-safe-integer-in-javascript
There is a maximum safe integer in JavaScript
One problem is representing large integers. The largest integer JavaScript can “safely” represent as a number is 9,007,199,254,740,991 or 2^53 - 1. (This is also available as a static property on Number: Number.MAX_...
🌐
Medium
medium.com › @avi2y07111999 › understanding-number-max-safe-integer-and-number-min-safe-integer-in-javascript-b6638d1d05e1
Understanding Number.MAX_SAFE_INTEGER and Number.MIN_SAFE_INTEGER in JavaScript | by Avinash kumar | Medium
July 31, 2025 - Number.MAX_SAFE_INTEGER: This constant represents the largest safe integer in JavaScript, with a value of 2^53 - 1, or 9007199254740991. Any integer larger than this risks losing precision due to the limitations of JavaScript's floating-point ...
🌐
Dirask
dirask.com › posts › JavaScript-random-float-number-in-range-with-exclusive-max-value-example-Ej4Gdp
JavaScript - random float number in range with exclusive max value example
// ONLINE-RUNNER:browser; /** * Generates random value in range. * * @param min inclusive minimal value (used as max value when max argument is undefined) * @param max exclusive maximal value * * @returns random float number in range <min, max) */ const randomFloat = (min, max) => { if (max == null) { max = (min == null ?
🌐
W3Schools
w3schools.com › jsref › jsref_max.asp
JavaScript Math max() Method
The Math.max() method returns the number with the highest value. ... Math.max() is an ECMAScript1 (JavaScript 1997) feature.
Top answer
1 of 16
1011

JavaScript has two number types: Number and BigInt.

The most frequently-used number type, Number, is a 64-bit floating point IEEE 754 number.

The largest exact integral value of this type is Number.MAX_SAFE_INTEGER, which is:

  • 253-1, or
  • +/- 9,007,199,254,740,991, or
  • nine quadrillion seven trillion one hundred ninety-nine billion two hundred fifty-four million seven hundred forty thousand nine hundred ninety-one

To put this in perspective: one quadrillion bytes is a petabyte (or one thousand terabytes).

"Safe" in this context refers to the ability to represent integers exactly and to correctly compare them.

From the spec:

Note that all the positive and negative integers whose magnitude is no greater than 253 are representable in the Number type (indeed, the integer 0 has two representations, +0 and -0).

To safely use integers larger than this, you need to use BigInt, which has no upper bound.

Note that the bitwise operators and shift operators operate on 32-bit integers, so in that case, the max safe integer is 231-1, or 2,147,483,647.

const log = console.log
var x = 9007199254740992
var y = -x
log(x == x + 1) // true !
log(y == y - 1) // also true !

// Arithmetic operators work, but bitwise/shifts only operate on int32:
log(x / 2)      // 4503599627370496
log(x >> 1)     // 0
log(x | 1)      // 1


Technical note on the subject of the number 9,007,199,254,740,992: There is an exact IEEE-754 representation of this value, and you can assign and read this value from a variable, so for very carefully chosen applications in the domain of integers less than or equal to this value, you could treat this as a maximum value.

In the general case, you must treat this IEEE-754 value as inexact, because it is ambiguous whether it is encoding the logical value 9,007,199,254,740,992 or 9,007,199,254,740,993.

2 of 16
509

>= ES6:

Number.MIN_SAFE_INTEGER;
Number.MAX_SAFE_INTEGER;

<= ES5

From the reference:

Number.MAX_VALUE;
Number.MIN_VALUE;

console.log('MIN_VALUE', Number.MIN_VALUE);
console.log('MAX_VALUE', Number.MAX_VALUE);

console.log('MIN_SAFE_INTEGER', Number.MIN_SAFE_INTEGER); //ES6
console.log('MAX_SAFE_INTEGER', Number.MAX_SAFE_INTEGER); //ES6

🌐
Fridoverweij
library.fridoverweij.com › docs › floating_points_in_js
Floating points in JavaScript
MAX_SAFE_INTEGER has 16 significant decimal digits. The 16th digit however, does not always guarantee a precise conversion, as shown above. The number of bits for the significand (length of the significand) determines the relative precision of the floating point format.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Math › max
Math.max() - JavaScript | MDN
console.log(Math.max(1, 3, 2)); // Expected output: 3 console.log(Math.max(-1, -3, -2)); // Expected output: -1 const array = [1, 3, 2]; console.log(Math.max(...array)); // Expected output: 3 ... Zero or more numbers among which the largest value will be selected and returned.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Number
Number - JavaScript | MDN
The largest value a number can hold is 21023 × (2 - 2-52) (with the exponent being 1023 and the mantissa being 0.1111… in base 2), which is obtainable via Number.MAX_VALUE.