note 30189 added to language.operators.bitwise
| From: | nash at nash dot nu | Date: | Mon, 10 Mar 2003 00:44:16 +0000 |
| Subject: | note 30189 added to language.operators.bitwise | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-45052@lists.php.net to get a copy of this message | ||
A previous comment indicates that << is actually a rotation operation.
I believe this is incorrect. Instead the behaviour is the same as C and many other languages.
Efectively you can consider all amounts to be modulo the size of the type. ie:
1 << 36 == 1 << (36 mod 32) == 1 << 4 == 16
This is generally an artifact of the architecture, rather then a specifically defined part of the
language. Hence such operations should be considered undefined. Note in partiular doing:
$x = $x << 32
to clear a int will NOT work, as it is effectively a no-op.
--
http://www.php.net/manual/en/language.operators.bitwise.php
http://master.php.net/manage/user-notes.php?action=edit+30189
http://master.php.net/manage/user-notes.php?action=delete+30189
http://master.php.net/manage/user-notes.php?action=reject+30189