title: GMP Bit shift doesn't work on negative numbers
body: <p>I found this function at php.net.  It seems to work on positive numbers, but fails on negative ones:</p>
  
  <pre><code>function gmp_shiftr($x,$n) { // shift right
    return(gmp_div($x,gmp_pow(2,$n)));
  } 
  
  echo -1 &gt;&gt; 8; //returns -1, presumably correctly
  echo "&lt;br /&gt;";
  echo gmp_strval(gmp_shiftr(-1,8)); //returns 0, presumably incorrectly
  </code></pre>
  
  <p>How could I fix up the function to work with negatives?</p>
  
  <p>Two ideas I have:</p>
  
  <p>Maybe I could do something along the lines of</p>
  
  <pre><code>if (whatever) { $a &gt;&gt; $b} else{ gmp_shiftr($a, $b) }?
  </code></pre>
  
  <p>Or, maybe I could subtract something from the negative results depending on their value..?</p>
  
  <p>I just want to get the value that >> would give, but also get it for >32bit numbers when I use GMP.</p>