Anutrix
Anutrix

Reputation: 273

Is Exclusive in XOR really appropriate for more than two inputs?

What does Exclusive in XOR really mean for more than two inputs? Doesn't word Exclusive suggest only one input must be true and not odd number of inputs. Note that the inputs are in sequence. This may seem like duplicate question but all similar questions answer for only two inputs and hence causes me confusion.

Upvotes: 3

Views: 1464

Answers (1)

n. m. could be an AI
n. m. could be an AI

Reputation: 119857

Exclusive OR is defined for two operands only, like e.g. addition. Just like an addition, it happens to be associative. This means

(a xor b) xor c = a xor (b xor c)

for all inputs a, b and c.

For associative operations, it is customary to drop parentheses because they cannot change meaning of an expression:

(a + b) + c = a + (b + c) = a + b + c
(a xor b) xor c = a xor (b xor c) = a xor b xor c

One can loosely speak of xor-ing together a bunch of values, but the underlying operation always takes two operands.

Upvotes: 5

Related Questions