Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site sdcc6.UUCP Path: utzoo!watmath!clyde!bonnie!akgua!sdcsvax!sdcc6!ix269 From: ix269@sdcc6.UUCP (Jim) Newsgroups: net.lang.c Subject: Re: Standard extensions (logical exclusive or) Message-ID: <1824@sdcc6.UUCP> Date: Thu, 15-Nov-84 05:40:02 EST Article-I.D.: sdcc6.1824 Posted: Thu Nov 15 05:40:02 1984 Date-Received: Fri, 16-Nov-84 07:02:57 EST References: <> <352@digi-g.UUCP>, <1442@pucc-h> <374@petsd.UUCP> Organization: U.C. San Diego, Academic Computer Center Lines: 58 (Hate inclusions, but could misquote elsewise :->) /* * I will answer the ?problem? lower down ---v */ > David L Stevens says: > > > The "opop" syntax is for allowing short circuit evaluation of > >boolean expressions. Thus && is there so that C can allow the programmer > >to optimize, where apropriate. Exclusive Or, on the other hand, requires > >that both operands be evaluated, so ^^ has no place. > > Since boolean expressions evaluate to 1 or 0, bitwise operations > >perform the same function as a non-short-circuit evaluation, and so & > >does it all. I don't see where you lose by using just ^. >> edit << > > I disagree. The bitwise operators operate on every bit of their arguments, > whereas the logical operators operate on zero -vs- non-zero. Therefore, i^j > is not the same as i^^j. i^^j is equivalent to: > i?(j?0:1):(j?1:0) > which is only the same as i^j when i and j are 0 or 1. > > Therefore, I vote for the ^^ operator. >> edit << > Full-Name: Joseph M. Orost > UUCP: ..!{decvax,ucbvax,ihnp4}!vax135!petsd!joe > US Mail: MS 313; Perkin-Elmer; 106 Apple St; Tinton Falls, NJ 07724 > Phone: (201) 870-5844 (Where do I vote :-) ?) Perhaps what you are searching for is this: if (( condB ) ^ ( condA )) /* conditionB XOR conditionA */ int x,y; char a,b; x = 1; y = 365; a = b = 't'; if ((x == y)^(a == b)) /* see? yes/no? */ putchar(a); else... although not all machines have booleans as 1, it is *hoped* that they will do it the same way everytime they do what they do. This should make TRUE some bit pattern and FALSE 0, FALSE should be 0 everywhere (meaning if it isn't where you are, send me mail so that I can avoid your county/state/machine :-).). The real question is perhaps, who needs this anyway? If you need it, please send me mail on what you use it for? Please. -=-=-=- -=-=-=- -=-=-=- -=-=-=- -=-=-=- < this disclaimer may have no intrinsic meaning. > Jim of HCDE {dcdwest,ucbvax}!sdcsvax!sdcc6!ix269 Usenet Arpanet (HCDE coming soon to be an illuminati near you)