Path: utzoo!utgpu!water!watmath!clyde!burl!codas!killer!jfh From: jfh@killer.UUCP (The Beach Bum) Newsgroups: comp.lang.c Subject: Re: swap macro -- beware -- oh yeah ? Summary: Watch closely everyone. I'll only do this once. Message-ID: <3147@killer.UUCP> Date: 29 Jan 88 06:49:50 GMT References: <8801200422.AA19420@decwrl.dec.com> <3061@killer.UUCP> <1182@ark.cs.vu.nl> Organization: Big "D" Home for Wayward Hackers Lines: 41 In article <1182@ark.cs.vu.nl>, maart@cs.vu.nl (Maarten Litmaath) writes: > In article <3061@killer.UUCP> jfh@killer.UUCP (John Haugh) writes: > \ a ^= b; > \ b ^= a; > \ a ^= b; [ I think this was the code in that article ] > \ > \What if, A and B are aliases? > \ > \ let's say, A = B = 7. > \ after a ^= b, both a and b == 0. > \ then, after both b ^= a and a ^= b (the second time), a and b > \ are STILL == 0. > > I think this is not true, you're making a mistake. > -- > Time flies like an arrow, fruit flies |Maarten Litmaath @ Free U Amsterdam: > like an orange. (seen elsewhere) |maart@cs.vu.nl, mcvax!botter!ark!maart I may have missed something in the definition of what an alias is, but in my book (okay Chris, I won't name names ;-), an alias is a different name for the same something. Different name, same storage, person, place, fruit fly, whatever. XOR - truth table. A B O+ (no overprinting here) 0 0 0 0 1 1 1 0 1 1 1 0 So far so good Maarten? What if, A and B are aliases? Well, wipe out the lines for A != B and what is left in the O+ column? 0. Now do this for all those bits. All 32 or whatever of them. You get 0. Lots of times. - John. -- John F. Haugh II SNAIL: HECI Exploration Co. Inc. UUCP: ...!ihnp4!killer!jfh 11910 Greenville Ave, Suite 600 "Don't Have an Oil Well? ... Dallas, TX. 75243 ... Then Buy One!" (214) 231-0993 Ext 260