title: PHP right shifting and negative result?
body: <p>I've run into a problem whilst converting some C code to PHP, specifically in the use of the right-shift operator.</p>
  
  <p><b>edit:</b> in the following examples, bit = 0;</p>
  
  <p>Original C code:</p>
  
  <pre><code>p-&gt;param-&gt;outBits[bytePtr++] |= codeword &gt;&gt; (9 + bit);
  </code></pre>
  
  <p>PHP code:</p>
  
  <pre><code>$outBits[$bytePtr++] |= $codeword &gt;&gt; (9 + $bit);
  </code></pre>
  
  <p>If I start with <code>codeword</code> being 130728, in C I get the expected result of -1.  In PHP I get 255.  I understand this is something to do with arithmetic/logical shift differences, and the negative sign not being introduced as a result of the MSBs staying at zero.</p>
  
  <p>Is there a "quick" way of doing the above in PHP that doesn't involve the shifting? eg via basic arithmetic or similar, that will give me the expected answer?</p>