Encodera

Thanks for reading!

Donate to the site — we work hard for you.

JavaScript reference

Number.MAX_SAFE_INTEGER

The largest integer that is stored without losing precision.

Available since: ES2015

Syntax

Number.MAX_SAFE_INTEGER

Return value

number9007199254740991, that is 2 to the power of 53 minus 1.

Examples

The value of the constant:

console.log(Number.MAX_SAFE_INTEGER);

Output:

9007199254740991

What happens past the limit:

const max = Number.MAX_SAFE_INTEGER;
 
console.log(max + 1 === max + 2);

Output:

true

Notes

Its pair is Number.MIN_SAFE_INTEGER, the same value with a minus. Do not confuse it with Number.MAX_VALUE, the largest number at all, which is no longer stored exactly.

See also

  • Number.isSafeInteger — Checks that an integer is within the range where it is stored exactly.
  • BigInt — Integers of any size, without loss of precision.
  • Number.EPSILON — The smallest difference between 1 and the next number — for comparing fractions.

Related recipes

In the tutorial

  • Numbers — Numbers in JavaScript — integers and fractions, rounding, the Math object, toFixed and the special values Infinity and NaN.

Thanks for reading!

Donate to the site — we work hard for you.