Bitwise operations with big integers
I am implementing decoding of BER-compressed integers and recently I've found a weird JavaScript behavior related to bitwise operations with big integers. E.g.: var a = 17516032; // has 25 bits alert(a << 7) // outputs -2052915200 alert(a * 128) // outputs 2242052096 alert(2242052096 >> 16) // outputs -31325 alert(2242052096 / 65536) // outputs 34211 While the first workaround (multiplication instead of left shift) is acceptable, the second isn't. Why it happens? How to bear with it? 17516032 in binary is 00000001000010110100011000000000 . Shifting to the left by 7 gives you