5 ms·
While I agree that in common language "or" frequently means "exclusive or", I believe that using "xor" to mean "exclusive or" is a bad choice, because "xor" is
by adrian_b 4y ago
While I agree that in common language "or" frequently means "exclusive or", I believe that using "xor" to mean "exclusive or" is a bad choice, because "xor" is ambiguous.
In computer programming, "xor" is always used with the meaning "sum modulo 2", never with the meaning "exclusive or", despite its etymology.
The 2 logical functions "exclusive or" and "sum modulo 2" are distinct. They coincide only when applied to two arguments, but they are very different when applied to 3 or more arguments.
"Exclusive or" of N Boolean values is true when one and only one of them is true. "Sum modulo 2" of N Boolean values is true whenever an odd number of them are true.
Both logical functions are very important and I find annoying that the name of "exclusive or" has been misapplied to "sum modulo 2".
- tempodox 4y agoI'd rather argue the opposite since XOR gates in hardware with more than 2 inputs also implement sum-modulo-2. Therefore I'd prefer the exactly-1-of-N-inputs-is-true (N > 1) function to be named differently.
- adrian_b 4y agoThese 2 logical functions have been named correctly and used so for centuries, so there is no need to change any name. The confusion between their names has appeared only some time around 1950, when someone of the designers of the first computers, while implementing in hardware the parity function, a.k.a. modulo-2 sum function, has decided nonetheless to give it the XOR mnemonic from the different "exclusive or" function. and then many others have followed this usage. It is OK now to use XOR, but one should always be well aware that XOR means parity a.k.a. modulo-2 sum, and not "exclusive or". I have replied to the parent comment, where the computer mnemonic "xor" was used to mean "exclusive or" in natural language, which is not recommended, as it may be not clear which is the intended meaning, because "xor", in its normal usage, does not mean "exclusive or". It should be noted that in mathematical notation, the 3 logical quantifiers "for all X ...", "there exists a X ..." and "there exists a unique X ..." correspond to the 3 logical functions "and", "or" and "exclusive or", and not to "and", "or" and "xor" (in the normal meaning of "xor").
- tempodox 4y agoThanks for that clarification :)
- saalweachter 4y agoNow that I think about it, we could have named it (bitwise) "ODD" and "EVEN" instead of "XOR" and "XNOR".
- yccs27 4y agoThe usage of "xor" as "sum modulo 2" is correct if you interpret it as composition of two-argument operators like a^b^c == a^(b^c). It's much easier to use infix notation with associative operators, so that is likely why the "sum mod 2" interpretation won. The "real xor of >2 arguments" is more useful with a notation like exactly_one(a,b,c).