For larger integers, consider using
|Property attributes of
MAX_SAFE_INTEGER constant has a value of
9007199254740991 (9,007,199,254,740,991, or ~9 quadrillion).
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 compare them correctly. For example,
Number.MAX_SAFE_INTEGER + 1 === Number.MAX_SAFE_INTEGER + 2 will evaluate to true, which is mathematically incorrect. See
Number.isSafeInteger() for more information.
MAX_SAFE_INTEGER is a static property of
Number, you always use it as
Number.MAX_SAFE_INTEGER, rather than as a property of a number value.
Number.MAX_SAFE_INTEGER; // 9007199254740991
Number.EPSILON is 2-52, while
MAX_SAFE_INTEGER is 253 – 1 — both of them are derived from the width of the mantissa, which is 53 bits (with the highest bit always being 1). Multiplying them will give a value very close — but not equal — to 2.
Number.MAX_SAFE_INTEGER * Number.EPSILON; // 1.9999999999999998
|ECMAScript Language Specification |
BCD tables only load in the browser