Boolean Operators Slighted in C
mesans
mesans at uvicctr.UUCP
Wed May 14 13:52:38 AEST 1986
>>Not quite the same.
>> 3 ^^ 4
>>would evaluate as 0,
>> 3 != 4
>>evaluates as 1.
>
>If the left and right hand sides are both already boolean, `!=' works;
>but the following macro always works:
>
> /* logical exclusive or */
> #define lxor(a, b) (((a) != 0) != ((b) != 0))
Which is equivalent to :
!a != !b
which I think you will agree is much simpler, and easyer to
understand (at least I think so).
S. John Banner
More information about the Comp.lang.c
mailing list