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