Path: utzoo!attcan!uunet!clyde.concordia.ca!mcgill-vision!snorkelwacker!usc!samsung!munnari.oz.au!metro!usage.csd.unsw.oz.au!spectrum!cameron From: cameron@usage.csd.oz (Cameron Simpson,Uhmmm..???? Who knows) Newsgroups: comp.std.c Subject: Re: Why no logical XOR operator Message-ID: <849@usage.csd.unsw.oz.au> Date: 13 Sep 90 09:34:25 GMT References: <1990Sep12.154515.18460@druid.uucp> Sender: news@usage.csd.unsw.oz.au Reply-To: cameron@spectrum.cs.unsw.oz.au (Cameron Simpson) Organization: none Lines: 20 From article <1990Sep12.154515.18460@druid.uucp>, by darcy@druid.uucp (D'Arcy J.M. Cain): | Recently I had occasion to write something like the following code: | if ((!x && (y & z)) || (x && !(y & z)) | something(); | Which would have been simpler as: | if (x ^^ (y & z)) | something(); | If there was such a thing as a '^^' operator. Does anyone know why C left | out the logical XOR operator? I can envisage two reasons: - It looks like && and ||, so it should short-circuit. This doesn't make sense for XOR. - What's wrong with saying: !!x ^ !!y which accomplishes exactly what you want. I'm tempted to use the phrase "insufficient utility". - Cameron Simpson cameron@spectrum.cs.unsw.oz.au