Standard extensions (logical exclusive or)

Doug Gwyn <gwyn> gwyn at brl-tgr.ARPA
Mon Nov 12 06:15:50 AEST 1984


> >	a^^b
> >
> >would be equivalent to
> >
> >	a? (b?0:1): (b?1:0)
>
> Another expression for a^^b is (a==0)^(b==0).
> Yet another one is (a!=0)^(b!=0).

To my mind, one of the sloppiest aspects of C is the omission of a true
Boolean data type and the substitution of "nonzero integer" instead.

The first expression given above at least has the advantage that it
does not require evaluating an operand more than once nor using bitwise
operators.

There are a total of 16 Boolean binary operators, some of which are
reducible to simpler expressions.  Allowing for "conditional" operators
(e.g. && ||) there are a few more possibilities.  How many of these
need to be in the language?



More information about the Comp.lang.c mailing list