Chad Minick
Software Developer

Shift Right Zero-fill in PHP

September 29, 2009 Comments

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.

comments powered by Disqus
Chad Minick | Software Developer
Twitter | Github | LinkedIn