Re:BigInt is finally here in ES2020
by MaxBarraclough on Monday March 01, 2021 @08:58AM
(#26302788)
> 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.
Ah, now I see it the whole point - "reliably representable" not meaning the same as "safe", gotcha.
Re:BigInt is finally here in ES2020
by MaxBarraclough on Monday March 01, 2021 @10:19AM
(#26303521)
Sort 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.
That 2^53 - 1 comes from the 64-Bit floating point representation JS uses for the normal number type.
edit: yeah, just as you wrote in the reply to the other comment