note 55842 deleted from language.operators.bitwise by victor
| From: | victor@php.net | Date: | Mon, 15 Aug 2005 10:45:44 +0000 |
| Subject: | note 55842 deleted from language.operators.bitwise by victor | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-93673@lists.php.net to get a copy of this message | ||
Note Submitter: kit dot lester at lycos dot co dot uk
----
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!