note 85305 deleted from language.operators.bitwise by danielc
| From: | danielc@php.net | Date: | Mon, 13 Apr 2009 16:14:13 +0000 |
| Subject: | note 85305 deleted from language.operators.bitwise by danielc | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-153170@lists.php.net to get a copy of this message | ||
Note Submitter: razboinik at gadast dot net
Reason: 2
----
i had a real bad time with bitwise operations
doesn't work well with unsinged 32 bits, this have reported elsewhere but it took me a while to
find a work around so here it is, taken from
http://brian.moonspot.net/2007/10/23/integer-conversion-issue/
function num_trans($value)
{
if ($value < 0)
$value += 0x100000000;
return $value;
}
function bitand($a, $b)
{
return num_trans($a)&num_trans($b);
}
function bitor($a, $b)
{
return num_trans($a)|num_trans($b);
}
function bitxor($a, $b)
{
return num_trans($a)^num_trans($b);
}