Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!ginosko!aplcen!haven!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: C history question Keywords: C design, XOR Message-ID: <19510@mimsy.UUCP> Date: 11 Sep 89 17:37:04 GMT References: <575@calmasd.Prime.COM> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 24 In article <575@calmasd.Prime.COM> wlp@calmasd.Prime.COM (Walter Peterson) writes: >C has bitwise operators for AND (&), OR (|) and XOR (^) and boolean >operator for AND (&&) and OR (||), but not for XOR (^^). Why? The best explanation I have ever heard is that the important property of && and || is not their `booleanness', but rather that they are short-circuit operators (they avoid evaluating the right hand side whenever the left hand side gives the answer by itself). By definition, exclusive or cannot short circuit, so the `^^' operator would be misleading. >... why make people go to the trouble of writing something like >(a || b) && (!(a && b)) when a ^^ b is so much "cleaner". The simplest expression for `boolean xor' is !a != !b since `!' is a boolean-normalising `not' operator and inverted inputs to xor still yeild xor. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris