Re^2: Bit Switching - How?

J.L.WOOD jlw at lznv.ATT.COM
Sat Apr 8 07:25:15 AEST 1989


> sl at van-bc.UUCP (pri=-10 Stuart Lynne) writes:
> \For fast generic swapping I use:
> 
> \#define	swap(a,b) {a^=b;b^=a;a^= b;}
> 

Also be careful how you use this algorithm if you are using pointers.
I once used this method in a sorting routine as my basic exchange and
got badly burned.

If a and b point to the same location, you get zero as in 0, nada, goose egg.

Joe Wood
jlw at lznv.ATT.COM



More information about the Comp.unix.questions mailing list