3 ms·
The problem with this technique is that it will not work for large numbers (in my build of node, for example, the largest number it will work with is 2^31 - 1:
by afshin 15y ago
The problem with this technique is that it will not work for large numbers (in my build of node, for example, the largest number it will work with is 2^31 - 1:
(Math.pow(2, 31) - 0.1) // base number
2147483647.9
~~(Math.pow(2, 31) - 0.1) // works!
2147483647
(Math.pow(2, 31) + 0.1) // base number
2147483648.1
~~(Math.pow(2, 31) + 0.1) // doesn't work!
-2147483648
- deleted 15y ago[deleted]