TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: KURT KUZBA
from: BILL BIRRELL
date: 1998-02-16 08:58:00
subject: `^=` and other bitwise operators

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)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.