4 ms·
JavaScript numbers are just floats and susceptible to precision loss as well as overflow to Infinity, aren't they? In fact, if incremented repeatedly, 64-bit f
by vbit 13y ago
JavaScript numbers are just floats and susceptible to precision loss as well as overflow to Infinity, aren't they?
In fact, if incremented repeatedly, 64-bit floats lose precision before 64-bit ints overflow.
- AndrewBissell 13y agoOh yes, floating point numbers have ALL SORTS of other issues. I was just stating the JS rationale for leaving ints out of the language, not saying I find it particularly convincing at all.
- masklinn 13y ago> 64-bit floats lose precision before 64-bit ints overflow. More precisely, a 64 bit IEEE 754 ("double precision") has 53 bits worth of "integer"[0], which allows for 15 digits (and almost, but not quite, 16: it can encode 15.95 decimal digits) [0] even though only 52 bits are allocated to the fraction, because the fraction part has an implicit 53rd bit set to 1 outside of special values