note 15953 added to language.operators.bitwise
| From: | joel at alpsgiken dot gr dot jp | Date: | Wed, 10 Oct 2001 05:58:56 +0000 |
| Subject: | note 15953 added to language.operators.bitwise | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-18762@lists.php.net to get a copy of this message | ||
All shifts are signed shifts. The shift is performed with the shift count modulo 32, which explains
the behavior which looks like a bit rotation, mentioned above.
Example:
$bit = 0x20000000;
print "$bit << 5 == " . ($bit << 5) . $prod . "<br />";
print "$bit >> 5 == " . ($bit >> 5) . $prod . "<br />";
print "$bit >> 37 == " . ($bit >> 37) . $prod . "<br />";
$bit = 4;
print "$bit >> 5 == " . ($bit >> 5) . $prod . "<br />";
print "$bit << 5 == " . ($bit << 5) . $prod . "<br />";
print "$bit << 37 == " . ($bit << 37) . $prod . "<br />";
Results:
536870912 << 5 == 0
536870912 >> 5 == 16777216
536870912 >> 37 == 16777216
4 >> 5 == 0
4 << 5 == 128
4 << 37 == 128
--
http://www.php.net/manual/en/language.operators.bitwise.php
http://master.php.net/manage/user-notes.php?action=edit+15953
http://master.php.net/manage/user-notes.php?action=delete+15953
http://master.php.net/manage/user-notes.php?action=reject+15953