w:Exclusive or

{{short description|True when either but not both inputs are true}}

{{Redirect|XOR|the logic gate|XOR gate|other uses|XOR (disambiguation)}}

{{refimprove|date=May 2013}}

{{Infobox logical connective

| title = Exclusive disjunction

| other titles = XOR

| Venn diagram = Venn0110.svg

| wikifunction = Z10237

| definition =

| truth table = (0110)

| logic gate = XOR_ANSI.svg

| DNF = \overline{x} \cdot y + x \cdot \overline{y}

| CNF = ( \overline{x} + \overline{y} ) \cdot ( x + y )

| Zhegalkin = x \oplus y

| 0-preserving = yes

| 1-preserving = no

| monotone = no

| affine = yes

| self-dual = no

}}

{{Logical connectives sidebar}}

File:Venn 0110 1001.svg of A \oplus B \oplus C|thumb|right]]

Exclusive or, exclusive disjunction, exclusive alternation, logical non-equivalence, or logical inequality is a logical operator whose negation is the logical biconditional. With two inputs, XOR is true if and only if the inputs differ (one is true, one is false). With multiple inputs, XOR is true if and only if the number of true inputs is odd.{{cite web|last1=Germundsson|first1=Roger|last2=Weisstein|first2=Eric|title=XOR|url=http://mathworld.wolfram.com/XOR.html|website=MathWorld|publisher=Wolfram Research|access-date=17 June 2015}}

It gains the name "exclusive or" because the meaning of "or" is ambiguous when both operands are true. XOR excludes that case. Some informal ways of describing XOR are "one or the other but not both", "either one or the other", and "A or B, but not A and B".

It is symbolized by the prefix operator J{{cite book |last1=Bocheński |first1=J. M. |title=Précis de logique mathématique |url=https://burjcdigital.urjc.es/bitstream/handle/10115/1425/PRECIS_DE_LOGIQUE_MATHEMATIQUE.pdf?sequence=1&isAllowed=y |date=1949 |location=The Netherlands |publisher=F. G. Kroonder, Bussum, Pays-Bas |language=French}} Translated as {{cite book |last1=Bocheński |first1=J. M. |translator-last=Bird |translator-first=O. |title=A Precis of Mathematical Logic |date=1959 |publisher=D. Reidel Publishing Company |url=https://archive.org/details/precisofmathemat0000boch/ |url-access=limited |doi=10.1007/978-94-017-0592-9 |location=Dordrecht, Holland|isbn=978-90-481-8329-6 }}{{rp|page=16}} and by the infix operators XOR ({{IPAc-en|ˌ|ɛ|k|s|_|ˈ|ɔ:|r}}, {{IPAc-en|ˌ|ɛ|k|s|_|ˈ|ɔ:}}, {{IPAc-en|'|k|s|ɔ:|r}} or {{IPAc-en|'|k|s|ɔ:}}), EOR, EXOR, \dot{\vee}, \overline{\vee}, \underline{\vee}, , \oplus, \nleftrightarrow, and \not\equiv.

Definition

File:Variadic logical XOR.svg is the truth table of the variadic XOR of the arguments shown on the left. E.g. row AB corresponds to the 2-circle, and row ABC to the 3-circle Venn diagram shown above. (As in the Venn diagrams, white is false, and red is true.)]]

The truth table of A\nleftrightarrow B shows that it outputs true whenever the inputs differ:

{{2-ary truth table|0|1|1|0|A\nleftrightarrow B}}

Equivalences, elimination, and introduction

Exclusive disjunction essentially means 'either one, but not both nor none'. In other words, the statement is true if and only if one is true and the other is false. For example, if two horses are racing, then one of the two will win the race, but not both of them. The exclusive disjunction p\nleftrightarrow q, also denoted by p\operatorname{?}q or Jpq, can be expressed in terms of the logical conjunction ("logical and", \and), the disjunction ("logical or", \vee), and the negation (\neg) as follows:

: \begin{matrix}

p\nleftrightarrow q & = & (p\vee q)\and\neg(p\and q)

\end{matrix}

The exclusive disjunction p \nleftrightarrow q can also be expressed in the following way:

: \begin{matrix}

p \nleftrightarrow q & = & (p \land \lnot q) \lor (\lnot p \land q)

\end{matrix}

This representation of XOR may be found useful when constructing a circuit or network, because it has only one \lnot operation and small number of \land and \lor operations. A proof of this identity is given below:

: \begin{matrix}

p \nleftrightarrow q & = & (p \land \lnot q) & \lor & (\lnot p \land q) \\[3pt]

& = & ((p \land \lnot q) \lor \lnot p) & \land & ((p \land \lnot q) \lor q) \\[3pt]

& = & ((p \lor \lnot p) \land (\lnot q \lor \lnot p)) & \land & ((p \lor q) \land (\lnot q \lor q)) \\[3pt]

& = & (\lnot p \lor \lnot q) & \land & (p \lor q) \\[3pt]

& = & \lnot (p \land q) & \land & (p \lor q)

\end{matrix}

It is sometimes useful to write p \nleftrightarrow q in the following way:

: \begin{matrix}

p \nleftrightarrow q & = & \lnot ((p \land q) \lor (\lnot p \land \lnot q))

\end{matrix}

or:

: \begin{matrix}

p \nleftrightarrow q & = & (p \lor q) \land (\lnot p \lor \lnot q)

\end{matrix}

This equivalence can be established by applying De Morgan's laws twice to the fourth line of the above proof.

The exclusive or is also equivalent to the negation of a logical biconditional, by the rules of material implication (a material conditional is equivalent to the disjunction of the negation of its antecedent and its consequence) and material equivalence.

In summary, we have, in mathematical and in engineering notation:

: \begin{matrix}

p \nleftrightarrow q & = & (p \land \lnot q) & \lor & (\lnot p \land q) & = & p\overline{q} + \overline{p}q \\[3pt]

& = & (p \lor q) & \land & (\lnot p \lor \lnot q) & = & (p + q)(\overline{p} + \overline{q}) \\[3pt]

& = & (p \lor q) & \land & \lnot (p \land q) & = & (p + q)(\overline{pq})

\end{matrix}

Negation of the operator

By applying the spirit of De Morgan's laws, we get:

\neg(p \nleftrightarrow q)\equiv\neg p\nleftrightarrow q\equiv p\nleftrightarrow\neg q.

Relation to modern algebra

Although the operators \wedge (conjunction) and \lor (disjunction) are very useful in logic systems, they fail a more generalizable structure in the following way:

The systems (\{T, F\}, \wedge) and (\{T, F\}, \lor) are monoids, but neither is a group. This unfortunately prevents the combination of these two systems into larger structures, such as a mathematical ring.

However, the system using exclusive or (\{T, F\}, \oplus) is an abelian group. The combination of operators \wedge and \oplus over elements \{T, F\} produce the well-known two-element field \mathbb{F}_2. This field can represent any logic obtainable with the system (\land, \lor) and has the added benefit of the arsenal of algebraic analysis tools for fields.

More specifically, if one associates F with 0 and T with 1, one can interpret the logical "AND" operation as multiplication on \mathbb{F}_2 and the "XOR" operation as addition on \mathbb{F}_2:

: \begin{matrix}

r = p \land q & \Leftrightarrow & r = p \cdot q \pmod 2 \\[3pt]

r = p \oplus q & \Leftrightarrow & r = p + q \pmod 2 \\

\end{matrix}

The description of a Boolean function as a polynomial in \mathbb{F}_2, using this basis, is called the function's algebraic normal form.{{cite book|title=Algorithmic Cryptanalysis|first=Antoine|last=Joux|publisher=CRC Press|year=2009|isbn=9781420070033|contribution=9.2: Algebraic normal forms of Boolean functions|pages=285–286|contribution-url=https://books.google.com/books?id=buQajqt-_iUC&pg=PA285}}

Exclusive or in natural language

Disjunction is often understood exclusively in natural languages. In English, the disjunctive word "or" is often understood exclusively, particularly when used with the particle "either". The English example below would normally be understood in conversation as implying that Mary is not both a singer and a poet.{{cite encyclopedia|last=Aloni|first=Maria|author-link=Maria Aloni|title=Disjunction|date=2016|url=https://plato.stanford.edu/archives/win2016/entries/disjunction/|encyclopedia=The Stanford Encyclopedia of Philosophy|editor-last=Zalta|editor-first=Edward N.|edition=Winter 2016|publisher=Metaphysics Research Lab, Stanford University|access-date=2020-09-03}}Jennings quotes numerous authors saying that the word "or" has an exclusive sense. See Chapter 3, "The First Myth of 'Or'":
{{cite book |last=Jennings |first=R. E. |date=1994 |title=The Genealogy of Disjunction |location=New York |publisher=Oxford University Press }}

:1. Mary is a singer or a poet.

However, disjunction can also be understood inclusively, even in combination with "either". For instance, the first example below shows that "either" can be felicitously used in combination with an outright statement that both disjuncts are true. The second example shows that the exclusive inference vanishes away under downward entailing contexts. If disjunction were understood as exclusive in this example, it would leave open the possibility that some people ate both rice and beans.

:2. Mary is either a singer or a poet or both.

:3. Nobody ate either rice or beans.

Examples such as the above have motivated analyses of the exclusivity inference as pragmatic conversational implicatures calculated on the basis of an inclusive semantics. Implicatures are typically cancellable and do not arise in downward entailing contexts if their calculation depends on the Maxim of Quantity. However, some researchers have treated exclusivity as a bona fide semantic entailment and proposed nonclassical logics which would validate it.

This behavior of English "or" is also found in other languages. However, many languages have disjunctive constructions which are robustly exclusive such as French soit... soit.

Alternative symbols

The symbol used for exclusive disjunction varies from one field of application to the next, and even depends on the properties being emphasized in a given context of discussion. In addition to the abbreviation "XOR", any of the following symbols may also be seen:

  • + was used by George Boole in 1847.{{cite book |last1=Boole |first1=G. |title=The Mathematical Analysis of Logic, Being an Essay Towards a Calculus of Deductive Reasoning |date=1847 |publisher=Macmillan, Barclay, & Macmillan/George Bell |location=Cambridge/London |page=17 |url=https://archive.org/details/mathematicalanal00booluoft}} Although Boole used + mainly on classes, he also considered the case that x,y are propositions in x+y, and at the time + is a connective. Furthermore, Boole used it exclusively. Although such use does not show the relationship between inclusive disjunction (for which \vee is almost fixedly used nowadays) and exclusive disjunction, and may also bring about confusions with its other uses, some classical and modern textbooks still keep such use.{{cite book |last1=Enderton |first1=H. |title=A Mathematical Introduction to Logic |orig-date=1972 |date=2001 |publisher=A Harcourt Science and Technology Company |location=San Diego, New York, Boston, London, Toronto, Sydney and Tokyo |page=51 |edition=2}}{{cite book |last1=Rautenberg |first1=W. |title=A Concise Introduction to Mathematical Logic |orig-date=2006 |date=2010 |publisher=Springer |location=New York, Dordrecht, Heidelberg and London |page=3 |edition=3}}
  • \overline{\vee} was used by Christine Ladd-Franklin in 1883.{{cite encyclopedia |last1=Ladd |first1=Christine |title=On the Algebra of Logic |url=https://archive.org/details/studiesinlogic00peiruoft/page/16|encyclopedia=Studies in Logic by Members of the Johns Hopkins University |editor1-last=Peirce |editor1-first=C. S. |publisher=Little, Brown & Company |location=Boston |date=1883 |pages=17–71}} Strictly speaking, Ladd used A\operatorname{\overline{\vee}}B to express "A is-not B" or "No A is B", i.e., used \overline{\vee} as exclusions, while implicitly \overline{\vee} has the meaning of exclusive disjunction since the article is titled as "On the Algebra of Logic".
  • \not=, denoting the negation of equivalence, was used by Ernst Schröder in 1890,{{cite book |last1=Schröder |first1=E. |title=Vorlesungen über die Algebra der Logik (Exakte Logik), Erster Band |date=1890 |publisher=Druck und Verlag B. G. Teubner |location=Leipzig |language=German}} Reprinted by Thoemmes Press in 2000.{{rp|page=307}} Although the usage of = as equivalence could be dated back to George Boole in 1847, during the 40 years after Boole, his followers, such as Charles Sanders Peirce, Hugh MacColl, Giuseppe Peano and so on, did not use \not= as non-equivalence literally which is possibly because it could be defined from negation and equivalence easily.
  • \circ was used by Giuseppe Peano in 1894: "a\circ b=a-b\,\cup\,b-a. The sign \circ corresponds to Latin aut; the sign \cup to vel." {{cite book |last1=Peano |first1=G. |title=Notations de logique mathématique. Introduction au formulaire de mathématique |date=1894 |publisher=Fratelli Boccna. |location=Turin}} Reprinted in {{cite book |last1=Peano |first1=G. |title=Opere Scelte, Volume II |url=https://archive.org/details/operescelte0002gius/page/n5/mode/2up |date=1958 |publisher=Edizioni Cremonese |location=Roma |pages=123–176}}{{rp|page=10}} Note that the Latin word "aut" means "exclusive or" and "vel" means "inclusive or", and that Peano use \cup as inclusive disjunction.
  • \vee\vee was used by Izrail Solomonovich Gradshtein (Израиль Соломонович Градштейн) in 1936.{{cite book |last1=ГРАДШТЕЙН |first1=И. С. |title=ПРЯМАЯ И ОБРАТНАЯ ТЕОРЕМЫ: ЭЛЕМЕНТЫ АЛГЕБРЫ ЛОГИКИ |url=https://www.mathedu.ru/text/gradshteyn_pryamaya_i_obratnaya_teoremy_1959/p0/ |orig-date=1936 |date=1959 |publisher=ГОСУДАРСТВЕННОЕ ИЗДАТЕЛЬСТВО ФИЗИКа-МАТЕМАТИЧЕСКОЙ ЛИТЕРАТУРЫ |location=МОСКВА |edition=3 |language=Russian}} Translated as {{cite book |last1=Gradshtein |first1=I. S. |translator-last1=Boddington |translator-first1=T. |title=Direct and Converse Theorems: The Elements of Symbolic Logic |date=1963 |publisher=Pergamon Press |location=Oxford, London, New York and Paris}}{{rp|page=76}}
  • \oplus was used by Claude Shannon in 1938.{{ cite journal

|last = Shannon

|first = C. E.

|author-link = Claude Elwood Shannon

|title = A Symbolic Analysis of Relay and Switching Circuits

|journal = Transactions of the American Institute of Electrical Engineers

|year = 1938

|volume = 57 |issue=12

|pages = 713–723

|doi= 10.1109/T-AIEE.1938.5057767

|hdl = 1721.1/11173

|s2cid = 51638483

|url = https://www.cs.virginia.edu/~evans/greatworks/shannon38.pdf

|hdl-access = free

}} Shannon borrowed the symbol as exclusive disjunction from Edward Vermilye Huntington in 1904.{{cite journal |last1=Huntington |first1=E. V. |title=Sets of Independent Postulates for the Algebra of Logic |journal=Transactions of the American Mathematical Society |date=1904 |volume=5 |issue=3 |pages=288–309|doi=10.1090/S0002-9947-1904-1500675-4 }} Huntington borrowed the symbol from Gottfried Wilhelm Leibniz in 1890 (the original date is not definitely known, but almost certainly it is written after 1685; and 1890 is the publishing time).{{cite book |last1=Leibniz |first1=G. W. |editor1-last=Gerhardt |editor1-first=C. I. |title=Die philosophischen Schriften, Siebter Band |url=https://archive.org/details/diephilosophisc01leibgoog/page/n11/mode/2up |access-date= 7 July 2023 |orig-date=16??/17??|date=1890 |language= German |publisher=Weidmann |location=Berlin |page=237}} While both Huntington in 1904 and Leibniz in 1890 used the symbol as an algebraic operation. Furthermore, Huntington in 1904 used the symbol as inclusive disjunction (logical sum) too, and in 1933 used + as inclusive disjunction.{{cite journal |last1=Huntington |first1=E. V. |title=New Sets of Independent Postulates for the Algebra of Logic, With Special Reference to Whitehead and Russell's Principia Mathematica |journal=Transactions of the American Mathematical Society |date=1933 |volume=35 |issue=1 |pages=274–304}}

  • \not\equiv, also denoting the negation of equivalence, was used by Alonzo Church in 1944.{{cite book |last1=Church |first1=A. |title=Introduction to Mathematical Logic |orig-date=1944|date=1996 |publisher=Princeton University Press |location=New Jersey |page=37}}
  • J (as a prefix operator, J\phi\psi) was used by Józef Maria Bocheński in 1949.{{rp|page=16}} Somebody{{cite book |title=Routledge Encyclopedia of Philosophy, Volume 8 |author-first=Edward |author-last=Craig |publisher=Taylor & Francis |date=1998 |isbn=978-0-41507310-3 |page=496 |url=https://books.google.com/books?id=mxpFwcAplaAC&pg=PA496}} may mistake that it is Jan Łukasiewicz who is the first to use J for exclusive disjunction (it seems that the mistake spreads widely), while neither in 1929{{cite book |title=Elementy logiki matematycznej |language=pl |trans-title=Elements of Mathematical Logic |author-last=Łukasiewicz |author-first=Jan |author-link=Jan Łukasiewicz |location=Warsaw, Poland |edition=1 |publisher=Państwowe Wydawnictwo Naukowe |date=1929}} nor in other works did Łukasiewicz make such use. In fact, in 1949 Bocheński introduced a system of Polish notation that names all 16 binary connectives of classical logic which is a compatible extension of the notation of Łukasiewicz in 1929, and in which J for exclusive disjunction appeared at the first time. Bocheński's usage of J as exclusive disjunction has no relationship with the Polish "alternatywa rozłączna" of "exclusive or" and is an accident for which see the table on page 16 of the book in 1949.
  • ^, the caret, has been used in several programming languages to denote the bitwise exclusive or operator, beginning with C{{cite book|title=The C Programming Language|title-link=The C Programming Language|year=1978|publisher=Prentice-Hall|first1=Brian W.|last1=Kernighan|author1-link=Brian Kernighan|first2=Dennis M.|last2=Ritchie|author2-link=Dennis Ritchie|contribution=2.9: Bitwise logical operators|pages=44–46|contribution-url=https://archive.org/details/TheCProgrammingLanguageFirstEdition/page/n51}} and also including C++, C#, D, Java, Perl, Ruby, PHP and Python.
  • The symmetric difference of two sets S and T, which may be interpreted as their elementwise exclusive or, has variously been denoted as S\ominus T, S\mathop{\triangledown} T, or S\mathop{\vartriangle} T.{{mathworld|title=Symmetric Difference|urlname=SymmetricDifference}}

Properties

{{glossary}}

{{term|Commutativity: yes}}{{defn|

{{aligned table

| style=text-align:center; border:1px solid darkgrey;

| rowstyle=;

| cols=3

| A \oplus B

|     \Leftrightarrow    

| B \oplus A

| 50px

|     \Leftrightarrow    

| 50px

}}

}}

{{term|Associativity: yes}}{{defn|

{{aligned table

| style=text-align:center; border:1px solid darkgrey;

| rowstyle=;

| cols=9

| ~A

| ~~~\oplus~~~

| (B \oplus C)

|     \Leftrightarrow    

|

|

| (A \oplus B)

| ~~~\oplus~~~

| ~C

| 50px

| ~~~\oplus~~~

| 50px

|     \Leftrightarrow    

| 50px

|     \Leftrightarrow    

| 50px

| ~~~\oplus~~~

| 50px

}}

}}

{{term|Distributivity:}}{{defn|The exclusive or does not distribute over any binary function (not even itself), but logical conjunction distributes over exclusive or. C\land(A \oplus B )= (C\land A) \oplus (C\land B) (Conjunction and exclusive or form the multiplication and addition operations of a field GF(2), and as in any field they obey the distributive law.)}}

{{term|Idempotency: no}}{{defn|

{{aligned table

| style=text-align:center; border:1px solid darkgrey;

| rowstyle=;

| cols=7

| ~A~

| ~\oplus~

| ~A~

|     \Leftrightarrow    

| ~0~

|     \nLeftrightarrow    

| ~A~

| 36px

| ~\oplus~

| 36px

|     \Leftrightarrow    

| 36px

|     \nLeftrightarrow    

| 36px

}}

}}

{{term|Monotonicity: no}}{{defn|

{{aligned table

| style=text-align:center; border:1px solid darkgrey;

| rowstyle=;

| cols=7

| A \rightarrow B

|     \nRightarrow    

|

|

| (A \oplus C)

| \rightarrow

| (B \oplus C)

| 50px

|     \nRightarrow    

| 50px

|     \Leftrightarrow    

| 50px

| \rightarrow

| 50px

}}

}}

{{term|Truth-preserving: no}}{{defn|When all inputs are true, the output is not true.

{{aligned table

| style=text-align:center; border:1px solid darkgrey;

| rowstyle=;

| cols=3

| A \land B

|     \nRightarrow    

| A \oplus B

| 50px

|     \nRightarrow    

| 60px

}}

}}

{{term|Falsehood-preserving: yes}}{{defn|When all inputs are false, the output is false.

{{aligned table

| style=text-align:center; border:1px solid darkgrey;

| rowstyle=;

| cols=3

| A \oplus B

|     \Rightarrow    

| A \lor B

| 60px

|     \Rightarrow    

| 50px

}}

}}

{{term|Walsh spectrum: (2,0,0,−2)}}

{{term|Non-linearity: 0}}{{defn|The function is linear.}}

{{term|Involution:}}{{defn|Exclusive or with one specified input, as a function of the other input, is an involution or self-inverse function; applying it twice leaves the variable input unchanged.

{{aligned table

| style=text-align:center; border:1px solid darkgrey;

| rowstyle=;

| cols=5

| ~A\oplus B~

| ~\oplus~

| ~B~

|     \Leftrightarrow    

| ~A~

| 50px

| ~\oplus~

| 50px

|     \Leftrightarrow    

| 50px

}}

}}

{{glossary end}}

If using binary values for true (1) and false (0), then exclusive or works exactly like addition modulo 2.

Computer science

=Bitwise operation=

{{Main article|Bitwise operation}}

File:Z2^4; Cayley table; binary.svg addition is the exclusive or of nonnegative integers in binary representation. This is also the vector addition in (\Z/2\Z)^4.]]

Exclusive disjunction is often used for bitwise operations. Examples:

  • 1 XOR 1 = 0
  • 1 XOR 0 = 1
  • 0 XOR 1 = 1
  • 0 XOR 0 = 0
  • {{n-ary|1110|2}} XOR {{n-ary|1001|2}} = {{n-ary|0111|2}} (this is equivalent to addition without carry)

As noted above, since exclusive disjunction is identical to addition modulo 2, the bitwise exclusive disjunction of two n-bit strings is identical to the standard vector of addition in the vector space (\Z/2\Z)^n.

In computer science, exclusive disjunction has several uses:

  • It tells whether two bits are unequal.
  • It is a controllable bit-flipper (the control input chooses whether or not to invert the data input).
  • It tells whether there is an odd number of 1 bits (A \oplus B \oplus C \oplus D \oplus E is true if and only if an odd number of the variables are true), which is equal to the parity bit returned by a parity function.

In logical circuits, a simple adder can be made with an XOR gate to add the numbers, and a series of AND, OR and NOT gates to create the carry output.

On some computer architectures, it is more efficient to store a zero in a register by XOR-ing the register with itself (bits XOR-ed with themselves are always zero) than to load and store the value zero.

In cryptography, XOR is sometimes used as a simple, self-inverse mixing function, such as in one-time pad or Feistel network systems.{{citation needed|date=June 2015}} XOR is also heavily used in block ciphers such as AES (Rijndael) or Serpent and in block cipher implementation (CBC, CFB, OFB or CTR).

In simple threshold-activated artificial neural networks, modeling the XOR function requires a second layer because XOR is not a linearly separable function.

Similarly, XOR can be used in generating entropy pools for hardware random number generators. The XOR operation preserves randomness, meaning that a random bit XORed with a non-random bit will result in a random bit. Multiple sources of potentially random data can be combined using XOR, and the unpredictability of the output is guaranteed to be at least as good as the best individual source.{{cite web|last=Davies|first=Robert B|title=Exclusive OR (XOR) and hardware random number generators|url=http://www.robertnz.net/pdf/xor2.pdf|access-date=28 August 2013|date=28 February 2002}}

XOR is used in RAID 3–6 for creating parity information. For example, RAID can "back up" bytes {{n-ary|10011100|2}} and {{n-ary|01101100|2}} from two (or more) hard drives by XORing the just mentioned bytes, resulting in ({{n-ary|11110000|2}}) and writing it to another drive. Under this method, if any one of the three hard drives are lost, the lost byte can be re-created by XORing bytes from the remaining drives. For instance, if the drive containing {{n-ary|01101100|2}} is lost, {{n-ary|10011100|2}} and {{n-ary|11110000|2}} can be XORed to recover the lost byte.{{cite web|last=Nobel|first=Rickard|title=How RAID 5 actually works|access-date=23 March 2017|date=26 July 2011|url=http://rickardnobel.se/how-raid5-works}}

XOR is also used to detect an overflow in the result of a signed binary arithmetic operation. If the leftmost retained bit of the result is not the same as the infinite number of digits to the left, then that means overflow occurred. XORing those two bits will give a "1" if there is an overflow.

XOR can be used to swap two numeric variables in computers, using the XOR swap algorithm; however this is regarded as more of a curiosity and not encouraged in practice.

XOR linked lists leverage XOR properties in order to save space to represent doubly linked list data structures.

In computer graphics, XOR-based drawing methods are often used to manage such items as bounding boxes and cursors on systems without alpha channels or overlay planes.

Encodings

It is also called "not left-right arrow" (\nleftrightarrow) in LaTeX-based markdown (\nleftrightarrow). Apart from the ASCII codes, the operator is encoded at {{unichar|22BB|XOR|html=}} and {{unichar|2295|CIRCLED PLUS|html=}}, both in block mathematical operators.

See also

Notes