The nonexistent ^^ operator
Darren Morbey
darren at revcan.UUCP
Wed Apr 10 05:57:01 AEST 1991
Pardon me for interrupting (I started this whole thing in the first
place) but I've gotten a lot of email and posted articles about
the bitwise xor. Unfortunately, our system has been down for
several days, so the article I planned to post, including your
comments and suggestions, will need _major_ rewriting to accomodate
all comments. I _will_ post some of the comments I have recieved
as well as other macros. Thanks to you all for sending.
I believe my request should be revised, however, regarding some
of the points made in these articles. In light of them, I revise
what I require here:
I would like to "simulate" ^^ i.e if( a ^^ b ) with a macro thus:
#define XOR(A,B) ...
The macro should accept all numeric types for A and B, treating them
as "0" or "non-0" as && and ||. If a macro is supplied, each operand
must be evaluated O&OO (once and only once.)
There are some things I knew and that I didn't know that I would like
to make clear that I know them now. They are as follows:
I KNEW there is no short-circuit evaluation for XOR as there is for
&& and ||. I want to guarantee that they are both executed anyway.
I DIDN'T KNOW && and || short circuited.
I DIDN'T KNOW !(a) is always an int.
I DIDN'T KNOW A?B:C means only one of B and C are evaluated.
I JUST REALIZED for certain A and B, my #1 could execute A _twice_
and B _not_ _at_ _all!_
I DID KNOW that #1 is unsatisfactory. It was put on as a general idea.
Please no more about it, but I do challenge anyone who can figure
out how my last statement is possible. I will post the answer later.
Other than that, please don't flog my dead horse. :-)
Thank you again for your comments. It will take a while to summarize
everything I have recieved. Until then, happy programming.
[ Darren Morby +1 613 957 9281 {uunet|lsuc|fts1}!revcan!darren ]
[ Revenue Canada Taxation, 3052-400 Cumberland St, Ottawa,ONT K1A 0L8 ]
[ "The challenge... is yours." -Dick Clark ]
More information about the Comp.lang.c
mailing list