note 55842 added to language.operators.bitwise
| From: | kit dot lester at lycos dot co dot uk | Date: | Mon, 15 Aug 2005 10:32:32 +0000 |
| Subject: | note 55842 added to language.operators.bitwise | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-93672@lists.php.net to get a copy of this message | ||
A C/assembler trick I use a lot --
$x^=$y; $y^=%x; $x^=$y;
will exchange the (integer) contents of $x and $y without needing an intermediate temporary variable
(the intermediate-temporary-variable method also takes three assignments...).
Draw the truth-tables of this if you don't believe it!
[In assembler days, this was known as "the treble-xor swap".]
Enjoy!
----
Manual Page -- http://www.php.net/manual/en/language.operators.bitwise.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+55842
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55842&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55842&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55842&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55842&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55842&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55842&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+55842&report=yes
Search -- http://master.php.net/manage/user-notes.php