using ^= to swap two integers (enough already)

Roy Smith roy at phri.UUCP
Tue Feb 12 01:50:07 AEST 1985


>To exchange two items without an intermediate variable, try:
> 	b ^= a ^= b ^= a
> [and so on and so on]

Who cares?  The xor trick may be cute, but if any programmer that works
for me tries to put that kind of crap in his code to make it run faster,
s/he should probably start looking for another job.  Can we move this to
net.lang.c.worthless.trivia?
-- 

The opinions expressed herein do not necessarily reflect
the views of the Public Health Research Institute.

allegra!vax135!timeinc\
   cmcl2!rocky2!cubsvax>!phri!roy (Roy Smith)
         ihnp4!timeinc/



More information about the Comp.lang.c mailing list