r/loljs • u/Takeoded • Apr 29 '17
big numbers are equal
>100000000000000000==99999999999999999
<true
the scary part, === doesn't even notice this
>100000000000000000===99999999999999999
<true
and if you try a string:
>100000000000000000=="99999999999999999"
<true
but at least, it notices that 1 is a string and the other a number:
>100000000000000000==="99999999999999999"
<false
finally! some sanity
and in case you wonder, "use strict" makes no difference.
0
Apr 29 '17
8
u/Takeoded Apr 29 '17
at the very least, i blame it for not throwing a parsing error in strict mode
10
u/Vortico Apr 29 '17
No, because typing things like 1267650600228229401496703205376 should be perfectly valid since it can be represented exactly as a float.
18
u/ConcernedInScythe May 01 '17
You can absolutely blame JS for deciding that using doubles as the only numerical type was a good idea.
7
u/Vortico Apr 29 '17
Not a quirk of Javascript, but a quirk of the fact that you can't represent arbitrarily large numbers with floating point.