JavaScript summing large integers
问题 In JavaScript I would like to create the binary hash of a large boolean array (54 elements) with the following method: function bhash(arr) { for (var i = 0, L = arr.length, sum = 0; i < L; sum += Math.pow(2,i)*arr[i++]); return sum; } In short: it creates the smallest integer to store an array of booleans in. Now my problem is that javascript apparently uses floats as default. The maximum number I have to create is 2^54-1 but once javascript reaches 2^53 it starts doing weird things: