Home > Uncategorized > Shift Right Zero-fill in PHP

Shift Right Zero-fill in PHP

September 29th, 2009

I found this on the internet, might come in handy.

< ?php
function zeroFill($a, $b) 
{ 
    $z = hexdec(80000000); 
        if ($z & $a) 
        { 
            $a = ($a>>1); 
            $a &= (~$z); 
            $a |= 0x40000000; 
            $a = ($a>>($b-1)); 
        } 
        else 
        { 
            $a = ($a>>$b); 
        } 
        return $a; 
}

credits to: Alex Stapleton, Andy Doctorow, Tarakan, Bill Zeller, Vijay “Cyberax” Bhatter, and traB.

Chad Emrys Minick Uncategorized

  1. No comments yet.
  1. No trackbacks yet.