This is about string representation; I've explained this in other threads. JS has one number format, but it *pretends* to make the distinction when converting to string, by notating floats with exact integer values differently (without a decimal point, unlike other languages).
-
-
Replying to @marcan42 @robertbak
Which is all fine and everything, until it starts spitting out decimal representations of integer values that aren't the actual integer value represented by a given float.
0 replies 0 retweets 0 likes -
This Tweet is unavailable.
-
This Tweet is unavailable.
-
This Tweet is unavailable.
-
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.
1 reply 0 retweets 0 likes -
Replying to @marcan42 @robertbak
Sure, it's repeatable, and it round-trips, but it's just /wrong/. If the float has a given value, and you print a *different* value, as an integer (not a decimal number that is obviously rounded), that's just messed up. Sure, you can *define* it that way, but still.
1 reply 0 retweets 0 likes -
Replying to @marcan42 @robertbak
Heck, even recent discussion and change to the BigInt spec agree: large Numbers are well-defined as integers. It's ridiculous that converting a Number to a BigInt (which is a safe operation) will change the number that is returned by toString.https://github.com/tc39/proposal-bigint/pull/138 …
0 replies 0 retweets 0 likes -
This Tweet is unavailable.
-
You deleted a tweet about 4611686018427388000 converting to the same number as BigInt. I can't test it because Chrome is using an older version of the draft that forbids that, but nope. Converting what JS calls 4611686018427388000 to BigInt would yield 4611686018427387904n.
1 reply 0 retweets 0 likes
This is also the case in Python and every other language with IEEE 754 64-bit floats: >>> int(4611686018427388000.0) 4611686018427387904 Because 4611686018427388000 is *not* an exact float64 value. 4611686018427387904 is.
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.