3 ms·
> This contrasts with JavaScript number values, which have the well-known property of only being able to precisely represent integers between -2⁵³ and 2⁵³. JS'
by deathanatos 7y ago
> This contrasts with JavaScript number values, which have the well-known property of only being able to precisely represent integers between -2⁵³ and 2⁵³.
JS's Number can represent way more integers than just those between -2⁵³ and 2⁵³. There's a great StackOverflow answer[1] that answers a similar question, ("What is the biggest "no-floating" integer that can be stored in an IEEE 754 double type without losing precision?") which also applies here (A JS Number is an IEEE double):
> The biggest/largest integer that can be stored in a double without losing precision is the same as the largest possible value of a double. That is, DBL_MAX or approximately 1.8 × 10³⁰⁸ (if your double is an IEEE 754 64-bit double). It's an integer. It's represented exactly. What more do you want?
> Go on, ask me what the largest integer is, such that it and all smaller integers can be stored in IEEE 64-bit doubles without losing precision. An IEEE 64-bit double has 52 bits of mantissa, so I think it's 2⁵³:
More seriously, this is great news, and I think it'll be nice to have such a numeric type in JS.
[1]: https://stackoverflow.com/a/1848762 https://stackoverflow.com/a/1848762
- deleted 7y ago[deleted]
- taeric 7y agoYou seem to be doing an uncharitable reading of what you quoted. They can precisely represent numbers outside that range, true. They cannot represent all numbers outside that range.
- chrisseaton 7y agoThat's obviously not what was intended by the question, come on.