swap via xor

Jay Maynard jay at splut.UUCP
Sat Feb 6 17:30:53 AEST 1988


In article <10366 at mimsy.UUCP>, chris at mimsy.UUCP (Chris Torek) writes:
> [...]  This is what whoever-it-was meant when he said
> that the first form could fail if a==b.  He did not mean `if the
> values are equal', he meant `if the variables are identical'.

This is a very clear explanation of the difference. Being the semi-converted
Pascalite that I am (why, jsut yesterday, I did some more work on a W-2
reporting package I wrote in Turbo, but that's not important right now), the
distinction was kinda lost on me (I saw the point that swap(p,p) didn't
work, but couldn't for the life of me figure out why you'd want to swap
something with itself!)

-- 
Jay Maynard, K5ZC (@WB5BBW)...>splut!< | GEnie: JAYMAYNARD  CI$: 71036,1603
uucp: {uunet!nuchat,academ!uhnix1,{ihnp4,bellcore,killer}!tness1}!splut!jay
Never ascribe to malice that which can adequately be explained by stupidity.
The opinions herein are shared by none of my cats, much less anyone else.



More information about the Comp.lang.c mailing list