note 85305 added to language.operators.bitwise
| From: | razboinik at gadast dot net | Date: | Mon, 25 Aug 2008 06:39:48 +0000 |
| Subject: | note 85305 added to language.operators.bitwise | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-143801@lists.php.net to get a copy of this message | ||
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);
}
----
Server IP: 69.147.83.197
Probable Submitter: 190.182.53.246
----
Manual Page -- http://www.php.net/manual/en/language.operators.bitwise.php
Edit -- https://master.php.net/note/edit/85305
Del: integrated -- https://master.php.net/note/delete/85305/integrated
Del: useless -- https://master.php.net/note/delete/85305/useless
Del: bad code -- https://master.php.net/note/delete/85305/bad+code
Del: spam -- https://master.php.net/note/delete/85305/spam
Del: non-english -- https://master.php.net/note/delete/85305/non-english
Del: in docs -- https://master.php.net/note/delete/85305/in+docs
Del: other reasons-- https://master.php.net/note/delete/85305
Reject -- https://master.php.net/note/reject/85305
Search -- https://master.php.net/manage/user-notes.php