🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #5128

the logical xor operator!

#5128
From: Maarten Litmaath
Date: Thu, 23 Jun 1988 21:48
19 lines
1000 bytes
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@cs.vu.nl, mcvax!botter!ark!maart
Technical Details
Message-ID: <1310@ark.cs.vu.nl>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcvax!botter!ark.cs.vu.nl!maart
References: <haddock.4604> <1719@ogcvax.ogc.edu> <1309@ark.cs.vu.nl>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcvax!botter!ark.cs.vu.nl!maart
From: maart@cs.vu.nl (Maarten Litmaath)
Newsgroups: comp.std.c
Subject: the logical xor operator!
Message-ID: <1310@ark.cs.vu.nl>
Date: 23 Jun 88 21:48:38 GMT
References: <haddock.4604> <1719@ogcvax.ogc.edu> <1309@ark.cs.vu.nl>
Reply-To: maart@cs.vu.nl (Maarten Litmaath)
Organization: VU Informatica, Amsterdam
Lines: 19