My point is that floats *are* Proper Integers: up to 53 bits they can represent every possible integer, and beyond that they can represent certain integers (but those integers, they represent exactly). JS is printing a *different* integer than what the float represents.
-
This Tweet is unavailable.
-
This Tweet is unavailable.
-
This Tweet is unavailable.
-
-
This Tweet is unavailable.
-
I'm not sure what number you're talking about. It's JS that is printing impossible numbers. 4611686018427387904 *is* possible to represent in float64. *Exactly*. With zero loss of precision. Absolutely, 100% exactly that number.
1 reply 0 retweets 0 likes -
Replying to @marcan42 @robertbak
4611686018427388000 is *not* possible to represent in float64. It does not exist on the set of possible float64 values. And yet, when you take 4611686018427387904, represent it as a float64 (which JS can do), and toString() it, JS returns 4611686018427388000 which is *wrong*!
1 reply 0 retweets 0 likes -
Replying to @marcan42 @robertbak
4611686018427387904 (decimal) == 2^62 == 0x1.0000000000000p+62 (float64) == [43 d0 00 00 00 00 00 00] (big-endian hex encoding of float64) are all representations of the same, exact, precise integer, with no loss or rounding. But JS's toString returns 4611686018427388000.
1 reply 0 retweets 0 likes -
Replying to @marcan42 @robertbak
Literally, the bytes inside a JS interpreter's RAM will contain [43 d0 00 00 00 00 00 00], per the IEEE 754 spec that *means 4611686018427387904*, and yet you call toString on that value and it returns something else. I don't know how to make this any clearer.
1 reply 0 retweets 0 likes -
Replying to @marcan42 @robertbak
Put another way: when given certain integer-valued floats and told to convert them to a string, JS is *returning a string that contains a different integer*. Sure it *rounds* to the same integer when converted to a float, but why muck it up?
1 reply 0 retweets 0 likes
That's like having a 50 dollar bill and saying I have a 53 dollar bill and claiming I'm right, because although a 53 dollar bill doesn't exist, the closest possible bill is a 50 dollar bill, which is what I have, so clearly it must be fine to say I have a 53 dollar bill.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.