What does Exclusive in XOR really mean?

北慕城南 提交于 2020-01-03 07:18:19

问题


Maybe this is just obvious to everyone but can someone explain where XOR (or Exclusive-OR) got its name from? What does the word Exclusive really mean? Not that it matters, but its just stuck in my head since morning.

OR:
0 0 0
0 1 1
1 0 1
1 1 1

XOR:
0 0 0
0 1 1
1 0 1
1 1 0

Is it "exclusively 0 for inputs 1,1", "special version of OR" or something else?


回答1:


XOR is an "exclusive OR" because it only returns a "true" value of 1 if the two values are exclusive, i.e. they are both different.




回答2:


It's what children understand as OR

You can have chocolate OR you can have ice cream

But a programmer would regard this as having both!

Q: "Would you like tea or coffee"
Annoying programmer answer = yes




回答3:


According to Knuth in Vol. 4A of TAOCP, George Boole "...wrote x+y to stand for disjunction, but he took pains to never use this notation unless x and y were mutually exclusive (not both 1). If necessary, he wrote x+(1-x)y to ensure that the result of a disjunction would never be 2."

XOR is addition with carries being lost.




回答4:


It's exclusive in the sense that the two operands must be mutually exclusive (in other words, different).




回答5:


This comes from set theory. Consider that you have two sets A and B, and an element which may or may not be in those sets. The first boolean input is true if the element is in set A. The second boolean input is true if the element is in set B.

If the element is "exclusive" to one set (as in "not shared" with the other) then the XOR operator will return true. Illustration from wikipedia:




回答6:


Exclusive in XOR means exactly what it says - one of the two has to be excluded. That is, either one or the other. Neither both, nor none - only one. At least that's how I've understood it :)




回答7:


It's exclusive as in "only one." In other words, it's "one of the two, but not both."




回答8:


I read a nice 'plain English' example today:

Consider, for example, the English sentence, "You pay me by Tuesday or I'll sue." If that "or" were the logical connective, then the sentence is true when either you do pay me by Tuesday or I sue you; so you could pay me on Monday and I still might sue you. But this particular use of "or" would normally be taken to mean that either you pay me by Tuesday and I don't sue you, or you do not pay me by Tuesday and I do sue you - the so-called "exclusive or".

Hugh Darwen, "An Introduction to Relational Database Theory", p76.



来源:https://stackoverflow.com/questions/5207240/what-does-exclusive-in-xor-really-mean

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!