Guajara in other languages: Spanish, Deutsch, French, Italian ...



Exclusive disjunction

In logic, exclusive disjunction is a logical operator. The exclusive disjunction of propositions A and B is usually called A xor B, where "xor" stands for "exclusive or" and is pronounced "eks-or".

The operation yields the result TRUE when one, and only one, of its operands is TRUE.

For two inputs A and B, the truth table of the function is as follows.

A B | A xor B
----+--------
F F |    F
F T |    T
T F |    T
T T |    F

It can be deduced from this table that

(A xor B) <=> (A and not B) or (not A and B) <=> (A or B) and (not A or not B) <=> (A or B) and not (A and B)

For more than two inputs, xor can be applied to the first two inputs, and then the result can be xor'ed with each subsequent input:

(A xor B xor C xor D) <=> (((A xor B) xor C) xor D)

Because xor is associative, the order of the inputs does not matter: the same result will be obtained regardless of order.

In general, the result of xor depends on the number of TRUE operands, if there are an odd number of TRUE operands, then the result will be TRUE, otherwise it will be FALSE.

The mathematical symbol for exclusive disjunction varies in the literature. In addition to the abbreviation "xor", one may see

Similarly, different textual notations are used, including "EOR" (with the same expansion as "xor") and "orr" (modelled on iff, of which it is the negative).

Binary values xor'ed by themselves are always zero. In some computer architectures, it is faster, or takes less space, to store a zero in a register by xor'ing the value with itself instead of loading and storing the value zero. Thus, on some computer architectures, xor'ing values with themselves is a common optimization.

The xor operation is sometimes used as a simple mixing function in cryptography, for example, with one-time pad or Feistel network systems.

See also: symmetric difference, or, and, xor swap algorithm, xor linked list, parity\n





Wikipedia - All text is available under the terms of the GNU Free Documentation License.

Tagoror dot com  -  Legal Information  -  Contact us