Hey Kurt,
KK > Yes. But the use of intermediate storage is faster.
KK > a ^= b; b ^= a; a ^= b;
I really can't see why everybody is getting so excited about
bitwise exclusive or assignments, or making improbable claims for them. It's
not as if it were a new technique. :-(
KK > In a program, you might use it like this:
KK > #define swap(a, b) ((b ^= (a ^= (b ^= a))))
Since this text replacement (macro expansion) occurs in the preprocessor,
any discussion of relative speeds at run time is meaningless, isn't it? Bob's
comments about sequence points OTOH are what is important.
Won't the memset(), memmove() &c functions (string.h) always be orders of
magnitude faster in operation anyway because they can make use of the
processor/memory intimacy that occurs only at machine level (block moves).
puzzled,
Bill.
---
---------------
* Origin: bill@escan.demon.co.uk (2:2504/200)
|