Binary Bitwise XOR Calculator
Calculate bitwise XOR of two binary numbers with bit-by-bit breakdown, truth table visualization, and multi-base output (BIN, DEC, HEX, OCT).
About
The XOR (exclusive OR) operation is fundamental to error detection, cryptography, and digital circuit design. A single flipped bit in a checksum or cipher key renders the entire output invalid. This calculator performs bitwise XOR on two binary operands up to 32 bits, producing results in binary, decimal, hexadecimal, and octal. It displays a bit-by-bit breakdown so you can trace exactly which bit positions differ between the two inputs - the core property of XOR where A ā B = 1 only when the operand bits are unequal.
The tool assumes unsigned integer representation. For inputs shorter than 32 bits, operands are zero-padded to equal length before the operation. Note: this calculator does not handle two's complement signed arithmetic. If you need signed XOR, convert your signed value to its unsigned binary form first. Pro tip: XOR is its own inverse - applying A ā B ā B returns A, which is why it appears in every stream cipher and RAID parity scheme.
Formulas
The bitwise XOR operation compares each corresponding bit of two operands. The result bit is 1 when the input bits differ and 0 when they are identical.
For each bit position i from 0 to n ā 1:
Where R is the result, A and B are the binary operands, n is the bit width (max 32), and ā denotes exclusive OR. The Hamming distance between two values equals the population count of their XOR:
Where popcount counts the number of 1-bits in the result. This metric is used in error-correcting codes and similarity measures.
Reference Data
| A | B | A ā B | Description |
|---|---|---|---|
| 0 | 0 | 0 | Both bits equal (zero) ā result 0 |
| 0 | 1 | 1 | Bits differ ā result 1 |
| 1 | 0 | 1 | Bits differ ā result 1 |
| 1 | 1 | 0 | Both bits equal (one) ā result 0 |
| Common XOR Properties | |||
| Commutative | A ā B = B ā A | ||
| Associative | (A ā B) ā C = A ā (B ā C) | ||
| Identity | A ā 0 = A | ||
| Self-Inverse | A ā A = 0 | ||
| Bitwise NOT via XOR | A ā 1...1 = ¬A | ||
| XOR Applications | |||
| Swap without temp | a = a ā b; b = a ā b; a = a ā b | ||
| Parity check | XOR all bits: result 1 ā odd parity | ||
| CRC checksums | Polynomial division via repeated XOR | ||
| One-time pad | Plaintext ā Key = Ciphertext | ||
| RAID 5 parity | Disk1 ā Disk2 ā ⦠= Parity | ||
| Gray code conversion | Gi = Bi ā Bi+1 | ||
| Find unique element | XOR all elements in array; duplicates cancel | ||
| Hamming distance | popcount(A ā B) counts differing bits | ||