XOR
XOR (Exclusive OR) is a logical operation that returns true if inputs differ. It is crucial in Boolean algebra, cryptography, error detection, and digital circuit design.
XOR (Exclusive OR) is a logical operation that returns true if inputs differ. It is crucial in Boolean algebra, cryptography, error detection, and digital circuit design.
XOR (Exclusive OR) is a logical operation that outputs true only when its inputs are different. In other words, XOR returns 1 if exactly one of the inputs is 1, and 0 otherwise.
It is widely used in Boolean algebra, digital electronics, programming, and cryptography.
| Input A | Input B | A XOR B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
XOR differs from the regular OR (A OR B), which outputs true if either or both inputs are true.
Most programming languages support XOR with the operator ^.
a = 5 # binary: 0101
b = 3 # binary: 0011
result = a ^ b # binary: 0110 -> decimal: 6
print(result) # Output: 6
Here, XOR compares each bit and outputs 1 only when the bits differ.
A XOR B XOR B = A.XOR is a fundamental logical operation with wide applications in computer science and electronics. By outputting true only when inputs differ, it enables efficient design of circuits, encryption methods, and error-checking algorithms.