First some background:
We know that JavaScript numbers are 64-bit values, but not all of those 64 bits are available to represent whole numbers. Hence JavaScript can NOT represent all of the 2^64
numbers.
It can, though, represent all the 2^52
whole numbers.
So the simple question is: is it absolutely not possible to do 64-bit binary to decimal conversions? Or are there some hacks.
Also, this is a bit perplexing, as I don't understand what's going on...
>>> str_64_1s = '1111111111111111111111111111111111111111111111111111111111111111'; >>> d = parseInt(str_64_1s, 2) 18446744073709552000 >>> d.toString(2) "10000000000000000000000000000000000000000000000000000000000000000" // 1 one + 64 zeros >>> parseInt(d.toString(2), 2) 18446744073709552000 >>> parseInt(d.toString(2), 2) === d true Math.pow(2, 64) == d true
Some related discussions: