In ECMA5 it says that the bitwise operators and shift operators operate on 32-bit ints, so in that case, the max safe integer is 2^31-1, or 2147483647.
However, the max safe integer otherwise is 2^53 - 1.
For my program, I need to potentially deal with integers between 2^32 and 2^53.
So, my question:
Currently in my code I do something like this:
value |= (byte & 127) << (7 * i);
This doesn't work with i
past 4 because it will be over the max shift range of 31.
So is the only alternative doing something like.. this? (still working on it)
value += (byte & 127) * Math.pow(10, i * 7);
Not completely correct but close enough to the point.. basically having to simulate ORing to a bitshift to get around the JavaScript restriction of 31 shift limits.
Is there a better way?