using ^= to swap two integers (e
preece at ccvaxa.UUCP
preece at ccvaxa.UUCP
Mon Feb 25 15:19:00 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?
------------
It's silly to beat dead horses like the need for making programs run faster;
if you have things where making things run a little faster will make them
viable, you know the need, if you can live with things written well and
not polished for speed, you're probably better off.
The argumentative tone is a little much, though. The xor trick isn't that
obscure and it's compact, so that attaching a simple comment explaining
what's happening should be sufficient to make it acceptable.
scott preece
gould/csd - urbana
ihnp4!uiucdcs!ccvaxa!preece
More information about the Comp.lang.c
mailing list