Use this bitwise XOR calculator to compare bits and return 1 where they differ. XOR (exclusive OR) is useful for toggling bits, simple encryption, and finding unique values.
Bitwise XOR calculator
Using the calculator
Enter two numbers and select an input format for each: Decimal, Hex, Binary, or Octal. You can also type prefixes directly (0xFF for hex, 0b1010 for binary, or 0o17 for octal) and the tool will auto-detect the format.
The result displays in all formats simultaneously: decimal (signed and unsigned), hexadecimal, octal, and a 32-bit binary representation with spaces every 8 bits for readability.
How bitwise XOR works
Bitwise XOR (exclusive OR, written as ^) compares each bit of two numbers. It returns 1 if the bits are different, and 0 if they are the same. Think of it as "one or the other, but not both."
The XOR truth table:
| A | B | A ^ B |
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Bitwise XOR example
Comparing the binary representations bit by bit:
00101100 (44)00011000 (24)
────────00110100 (52)
Positions where the bits differ produce a 1 in the result. In other words: 44 ^ 24 = 52.
Common uses for XOR
Toggle bits: XOR with 1 flips a bit, XOR with 0 keeps it the same. Useful for switching flags on and off.
Simple encryption: XORing data with a key scrambles it; XORing again with the same key recovers the original (since a ^ b ^ b = a).
Swap without temp: You can swap two variables using three XOR operations: a ^= b; b ^= a; a ^= b;
Find unique element: XOR all elements in an array where every element appears twice except one - the result is the unique element.
