Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!hplabs!otter.hpl.hp.com!hpltoad!cdollin!kers From: kers@hplb.hpl.hp.com (Chris Dollin) Newsgroups: comp.lang.c Subject: Re: The nonexistent operator (along = v. == lines) Message-ID: Date: 5 Apr 91 14:11:31 GMT References: <156@revcan.UUCP> <157@revcan.UUCP> <1991Apr3.203748.3226@neon.Stanford.EDU> Sender: news@hplb.hpl.hp.com (Usenet News Administrator) Organization: Hewlett-Packard Laboratories, Bristol, UK. Lines: 21 In-Reply-To: dkeisen@Gang-of-Four.Stanford.EDU's message of 3 Apr 91 20:37:48 GMT Nntp-Posting-Host: cdollin.hpl.hp.com Dave Eisen writes (apropos of the ``xor'' discussion): #define XOR(a,b) (!!(a) ^ !!(b)) does what you want. Hmm ... we can strip one of the !'s from each pair to get (!(a) ^ !(b)) If the XOR is likely to be used in conditional contexts (rather than value contexts) then I'd guess that more compilers could optimise equality tests than ^ instructions (because more machines have some sort of branch-if-(n)eq), so how about #define XOR(a,b) (!(a) != !(b)) -- Regards, Kers. | "You're better off not dreaming of the things to come; Caravan: | Dreams are always ending far too soon."