Boolean Operators Slighted in C
Daniel R. Levy
levy at ttrdc.UUCP
Mon May 12 08:27:43 AEST 1986
In article <732 at steinmetz.UUCP>, davidsen at steinmetz.UUCP (Davidsen) writes:
>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
or even
#define XOR(a,b) (!(a) != !(b))
since XOR(not-a,not-b) == XOR(a,b)
--
------------------------------- Disclaimer: The views contained herein are
| dan levy | yvel nad | my own and are not at all those of my em-
| an engihacker @ | ployer or the administrator of any computer
| at&t computer systems division | upon which I may hack.
| skokie, illinois |
-------------------------------- Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa,
vax135}!ttrdc!levy
More information about the Comp.lang.c
mailing list