Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   PHP (http://www.programmingforums.org/forum29.html)
-   -   Bitwise Operator Question (http://www.programmingforums.org/showthread.php?t=11864)

grimpirate Nov 13th, 2006 2:29 AM

Bitwise Operator Question
 
I looked in the documentation and searched around the forum, but there doesn't seem to be a function for circularly rotating (shifting) bits in a bitwise fashion. Wondering if anyone knows one of the top of their head or if there's something I overlooked in the manual? Thx for the help.

grimpirate Nov 13th, 2006 3:39 AM

Never mind it was on the php.net site but not in the manual. Someone was nice enough to post the function that they use
[PHP]function bitRotate32($value,$amount) {
if ($amount>0) {
$amount %= 32;
$value = ($value<<$amount) | ($value>>(32-$amount));
} elseif ($amount<0) {
$amount = -$amount%32;
$value = ($value>>$amount) | ($value<<(32-$amount));
}
return $value;
}[/PHP]


All times are GMT -5. The time now is 1:27 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC