CKTIS / JavaScript
Number.MAX_SAFE_INTEGER: upper safe-integer boundary
Number.MAX_SAFE_INTEGER has the exact value 2^53−1, or 9007199254740991, and marks the positive boundary of Number’s safe integer range.
Version: ECMAScript 2015 onward; example target: Node.js 24.22.2
Syntax
Number.MAX_SAFE_INTEGERNumber.MAX_SAFE_INTEGER equals 2 ** 53 - 1, exactly 9007199254740991. Integral Number values from Number.MIN_SAFE_INTEGER through this boundary are safe integers: consecutive integers can be represented without rounding collisions. The constant is not the largest finite Number; the much larger Number.MAX_VALUE fills that role.
2 ** 53 is still exactly representable, but is not classified as safe because not every consecutive integer remains distinguishable. For example, Number.MAX_SAFE_INTEGER + 1 and Number.MAX_SAFE_INTEGER + 2 produce the same Number. Checking only after converting a long textual identifier can be too late, because precision may already have been lost during parsing.
The property has existed since ECMAScript 2015 and is non-writable, non-enumerable, and non-configurable. The example validates a non-negative identifier with Number.isSafeInteger and the explicit boundary, then demonstrates the first collision. For larger identifiers, preserve text or use BigInt instead of converting them to Number.
Examples
const limit = Number.MAX_SAFE_INTEGER;
const validId = value => Number.isSafeInteger(value) && value >= 0 && value <= limit;
console.log(limit, limit === 2 ** 53 - 1);
console.log(limit + 1 === limit + 2);
console.log(validId(limit), validId(limit + 1));
const descriptor = Object.getOwnPropertyDescriptor(Number, "MAX_SAFE_INTEGER");
console.log(descriptor.writable, descriptor.enumerable, descriptor.configurable);Result
9007199254740991 true true true false false false false
Number.MAX_SAFE_INTEGER → identifier validation and the first rounding collision