4 ms·
The point is that not all integers over `Number.MAX_SAFE_INTEGER` can be represented. Some can, of course. That 2^53 - 1 comes from the 64-Bit floating point r
by seritools 6y ago
The point is that not all integers over `Number.MAX_SAFE_INTEGER` can be represented. Some can, of course.
That 2^53 - 1 comes from the 64-Bit floating point representation JS uses for the normal number type.
(Number.MAX_SAFE_INTEGER + 1) === (Number.MAX_SAFE_INTEGER + 2)
> true
edit: yeah, just as you wrote in the reply to the other comment
- MaxBarraclough 6y ago> The point is that not all integers over `Number.MAX_SAFE_INTEGER` can be represented. Some can, of course. Right. This contradicts the article. > 2^53 - 1 comes from the 64-Bit floating point representation JS uses Right.
- seritools 6y agoAh, now I see it the whole point - "reliably representable" not meaning the same as "safe", gotcha.
- MaxBarraclough 6y agoSort of. I'm pointing out what seems to me to be an incorrect statement in the article. I think it's reasonable to have special terminology for the sequence of contiguous integers which can be represented exactly in the Number type. Safe seems a reasonable choice, provided it's used carefully. MAX_SAFE_INTEGER seems a better choice of identifier than something like MAX_VALUE_OF_EXACTLY_REPRESENTABLE_CONTIGUOUS_SEQUENCE_OF_INTEGERS, of course, despite that it's less precise. (Even that absurdly long identifier isn't perfectly precise, as we can define a trivial sequence of a single value like Number.MAX_VALUE.) The documentation explaining it should be precise, though.