the logical xor operator!

Maarten Litmaath maart at cs.vu.nl
Fri Jun 24 07:48:38 AEST 1988


Hello, it's me again.
This time the question is: why hasn't C got a logical xor operator?

	logical and: &&
	logical or:  ||
	logical xor: ^^		<- fits nicely!

Of course the way to come around the deficiency is:

	if (!(expr1) != !(expr2)) {
		...
	}

but this only works if !0 always evaluates to the same value (viz. 1), that is,
the optimizer is not allowed to f*ck around with the comparison.
!0 is indeed a constant, isn't it?
-- 
I'd rather live in Russia             |Maarten Litmaath @ Free U Amsterdam:
              than in South-Africa... |maart at cs.vu.nl, mcvax!botter!ark!maart



More information about the Comp.std.c mailing list