01

Why XOR is its own inverse

Exclusive OR returns 1 when its two inputs differ and 0 when they match. Two consequences follow immediately, and together they make XOR the most useful bitwise operation in low-level programming.

The two identitiesx ⊕ x = 0
x ⊕ 0 = x

Apply the first identity to a ⊕ b = c. XOR both sides by b: a ⊕ b ⊕ b = c ⊕ b, and since b ⊕ b = 0 the left side collapses to a. So a = c ⊕ b. The same trick recovers whichever operand is unknown, which is why no search or inversion table is needed.

XOR truth table
aba ⊕ b
000
011
101
110

The table is symmetric and every output column contains one 0 and one 1 — that balance is exactly what makes the operation invertible. AND and OR do not have this property, which is why they cannot be undone without extra information.

02

Worked example

Suppose 1011 ⊕ b = 0110 and you want b. XOR the two known values bit by bit: 1⊕0 = 1, 0⊕1 = 1, 1⊕1 = 0, 1⊕0 = 1. That gives 1101, which is 13 in decimal and 0xD in hex.

Check by putting it back: 1011 ⊕ 1101 = 0110. The check row in the tool performs exactly this, so a transcription slip in your inputs shows up immediately.

Bit-by-bit recovery
Positionacb = a ⊕ c
bit 3 (MSB)101
bit 2011
bit 1110
bit 0 (LSB)101

When the operands have different lengths the tool pads the shorter one with leading zeros, so 1011 and 1101 are treated as 4-bit values. That padding is a convention, not a mathematical necessity — the bit width is a property of how you are storing the number, not of the operation.

03

Where the self-inverse property is used

  • Swapping without a temporary — a ^= b; b ^= a; a ^= b exchanges two registers. Modern compilers emit a temporary anyway, so this is a curiosity rather than an optimisation.
  • RAID 5 parity — the parity block is the XOR of all data blocks. If a disk fails, XOR the survivors to reconstruct it.
  • Simple checksums — XOR all bytes; any single-bit error changes the result. Weak, but cheap enough for firmware.
  • Stream ciphers — encrypt with c = p ⊕ k and decrypt with p = c ⊕ k, using the same key. The one-time pad is the only provably unbreakable cipher, and it is pure XOR.
  • Finding the unique element — XOR a list where every value appears twice except one, and the survivor is that value.

XOR alone is not encryption. Reusing a key across two messages leaks their XOR, and any known plaintext reveals the key. XOR is the mechanism, not the security — that comes from key generation and non-reuse.

04

Bit width and sign

XOR is defined on bit patterns, not on numbers, so the result depends on how many bits you consider. In 4 bits, 1011 ⊕ 0110 = 1101 = 13. In 8 bits the same operands are 00001011 and 00000110, and the answer is 00001101 — still 13, because leading zeros XOR to zero.

Negative numbers only enter the picture through two's complement, where the top bit carries a sign. There the bit pattern is inverted rather than the magnitude, which is why XOR-based tricks on signed integers behave differently from the same tricks on unsigned ones.

The tool reports the bit width it inferred from your longest input, so you can see exactly which representation produced the answer.

05

XOR in checksums and parity

A parity byte is the XOR of all the data bytes. If any single byte is corrupted, recomputing the parity reveals a mismatch — and if exactly one byte is missing, XOR recovers it exactly.

A four-byte parity block
ByteValueNotes
Data 10xA3
Data 20x5C
Data 30xF1
Parity0x0E0xA3 ⊕ 0x5C ⊕ 0xF1
Recover data 30xF10xA3 ⊕ 0x5C ⊕ 0x0E

The scheme detects any odd number of bit errors but misses even numbers, because two flips cancel in the XOR. That is why real storage systems use stronger codes — but the principle, that XOR makes one missing value recoverable, is the same one RAID 5 uses across whole disks.

?

Frequently asked questions

What is 1011 XOR 0110?

1101, which is 13 in decimal and 0xD in hexadecimal. Each bit is compared independently: 1⊕0=1, 0⊕1=1, 1⊕1=0, 1⊕0=1.

Why must exactly one field be empty?

Because the tool recovers the unknown from the other two. With two blanks there are infinitely many consistent answers; with no blanks there is nothing to compute.

Is XOR the same as addition without carrying?

Yes, for single bits. Addition and XOR agree on 0+0, 0+1 and 1+0, and differ only on 1+1, where addition carries and XOR does not. That is why XOR appears in checksum and CRC algorithms.

Can I use decimal inputs?

This tool works on binary strings, so convert first. The result rows show the decimal and hex equivalents so you can convert back without a second step.

Why does XOR recover the odd one out in a list?

Because every duplicated value cancels itself: x ⊕ x = 0, and 0 leaves everything else unchanged. XOR the whole list and only the unpaired value survives.