Boolean Operators Slighted in C
Davidsen
davidsen at steinmetz.UUCP
Sat May 10 05:59:39 AEST 1986
In article <210 at sdchema.sdchem.UUCP> tps at sdchema.UUCP (Tom Stockfisch) writes:
>In article <778 at bentley.UUCP> kwh at bentley.UUCP writes:
>>In article <838 at ihwpt.UUCP> ihwpt!knudsen writes:
>>>(2) There isn't any ^^ (XOR) operator either, as in
>>
>>There is, but it's spelled "!=". (Presumably more efficient than "^", though
>>I think either one should work with a smart compiler.)
>>
>
>Not quite the same.
> 3 ^^ 4
>would evaluate as 0,
> 3 != 4
>evaluates as 1.
>
>-- Tom Stockfisch, UCSD Chemistry
XOR can be defined as an (ugly) macro, I believe.
#define XOR(a,b) (((a) != 0) != ((b) != 0)
/* or if you like small better than readable */
#define XOR(a,b) (!!(a) != !!(b))
--
-bill davidsen
seismo!rochester!steinmetz!--\
/ \
ihnp4! unirot ------------->---> crdos1!davidsen
\ /
chinet! ---------------------/ (davidsen at ge-crd.ARPA)
"Stupidity, like virtue, is its own reward"
More information about the Comp.lang.c
mailing list