Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site uwai.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!uwvax!uwai!tom From: tom@uwai.UUCP Newsgroups: net.lang.c Subject: Re: Standard extensions (logical exclusive or) Message-ID: <155@uwai.UUCP> Date: Sun, 11-Nov-84 09:54:09 EST Article-I.D.: uwai.155 Posted: Sun Nov 11 09:54:09 1984 Date-Received: Mon, 12-Nov-84 07:18:11 EST References: <374@petsd.UUCP> <3081@alice.UUCP> Organization: U of Wisconsin CS Dept Lines: 35 > Joseph Orost suggests a new operator ^^ such that > > a^^b > > would be equivalent to > > a? (b?0:1): (b?1:0) > > What is wrong with writing > > a!=b > > for this purpose? Consider the following: a = 5; b = 6; if ( a ^^ b ) foo(); /* foo would not execute - both a and b are true */ Now, if you said if ( a != b) boo(); /* foo would execute - a and b not the same */ you would not get the same thing, since I believe that the ^^ operator should treat its operands as strictly logicals, ie, force a !! coversion on each of them, just as the && and || operators do. I suppose you could say if ( !!a != !!b ) foo(); but there is something to be said for the elegance of ^^. I find myself of need of it now and again. -- Tom Christiansen University of Wisconsin Computer Science Systems Lab ...!{allegra,heurikon,ihnp4,seismo,uwm-evax}!uwvax!tom tom@wisc-crys.arpa