XOR gate
An XOR gate (exclusive OR gate) is a digital logic gate that implements logical exclusive OR; that is, it outputs true (1) only when the inputs differ (one is true, the other is false). If both inputs are false (0) or both are true (1), the output is false (0).
The XOR gate can accept two or more inputs, though two inputs are most common. For a two-input XOR gate, the output is true if and only if exactly one of the inputs is true. An XOR gate with more than two inputs is often referred to as an "odd parity" function; it outputs true if an odd number of its inputs are true.
The XOR gate is widely used in digital circuits for tasks such as arithmetic operations (e.g., adders), comparators, and error detection/correction. Its function is often represented by the symbol ⊕. The logical expression for a two-input XOR gate with inputs A and B and output Q is: Q = (A AND NOT B) OR (NOT A AND B), which can also be written as Q = A ⊕ B.
The opposite of the XOR gate is the XNOR gate (exclusive NOR gate), which outputs true if the inputs are the same, and false if the inputs differ.