Say I’ve got two coins. They can each take on two states (heads or tails). Flip em both; xor
can tell you if they showare different states (not-equal coin sides).
CoinA | CoinB | XOR ("are they different?")
--------------------
heads | heads | no
tails | tails | no
heads | tails | yes
tails | heads | yes
In boolean terms this would of course map to heads=0
, tails=1
, no=0
, yes=1
for example.
Replace "they" here for "coin sides" or "states" or "inputs" as it seems fitting for the explanation. Maybe it makes it clearer when talking about "are they both/all equal/different" to underline the "exclusiveness" of xor
.
This can also (maybe later on) lead to the awareness that not xor
("not different") is the same as "equality" (==
operator) with the paraphrasing question "Are they not different (=equal)?". So "all are different" or "all are same" are inverse to each other.
The name has exclusive in it because when xor is yes/1/true, the heads are exclusive. That is, one head excludes the other. This is also true for the tails.