PHP equilavent javascript >>> shift right with zero fill bitwise operators?

Posted by neobie on Stack Overflow See other posts from Stack Overflow or by neobie
Published on 2010-04-15T00:52:54Z Indexed on 2010/04/15 1:13 UTC
Read the original article Hit count: 292

Filed under:
|
|
|

May I know how can I do PHP >>> ? Such operators is not available in PHP, but is available in Javascript.

I just managed to discover a function as follow:

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; 
}

but unfortunately, it doesn't work perfectly.

© Stack Overflow or respective owner

Related posts about php

Related posts about bitwise