home *** CD-ROM | disk | FTP | other *** search
- Path: cs.ruu.nl!usenet
- From: wsldanke@cs.ruu.nl (Wessel Dankers)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: x ^= y ^= x ^= y;
- Date: 24 Feb 96 18:00:24 +0100
- Organization: Dept of Computer Science, Utrecht University, The Netherlands
- Message-ID: <972.6628T1080T1212@cs.ruu.nl>
- References: <4glcf7$eou@wn1.sci.kun.nl>
- NNTP-Posting-Host: anx1p10.cc.ruu.nl
- X-Newsreader: THOR 2.22 (Amiga TCP/IP)
-
-
- Olaf Seibert <rhialto@mbfys.kun.nl> wrote:
- >In <1286.6624T1439T237@cs.ruu.nl> wsldanke@cs.ruu.nl (Wessel Dankers) writes:
- >>Which can of course be rewritten as:
- >>
- >> x ^= y;
- >> y ^= x;
- >> x ^= y;
- >>
- >>or if you want it real fancy:
- >>
- >> x ^= y ^= x ^= y;
-
- >No. you can't do this last step. You are modifying the same variable
- >(two variables even) twice between sequence points.
-
- It has been tested and used. Remember that the ^= is right associative:
- read it as:
-
- x ^= (y ^= (x ^= y));
-
- The result-value of (x ^= y) is equal to the new value of x, mutatis mutandis
- for (y ^= x).
-
- --
- Wessel Dankers _\\|//_ <wsldanke@cs.ruu.nl>
- ///|\\\
- ----------------------------oOO--(_)---OOo----------------------------
- `Never imagine yourself not to be otherwise than what it might appear
- to others that what you were or might have been was not otherwise than
- what you had been would have appeared to them to be otherwise.'
-
-