XOR, short for 'exclusive OR', is a logical/bitwise operation that returns true (or 1) only when its two inputs differ โ if both bits are the same (both 0 or both 1), XOR returns 0. This XOR calculator lets you enter two numbers, either in decimal or binary, and instantly computes the bitwise XOR result along with the binary expansion of each value so you can see exactly which bits flipped. It's built for computer science students learning boolean logic and bitwise operators, programmers who need a quick sanity check while debugging bit-manipulation code, and electronics students studying logic gates.
XOR shows up constantly in real applications: simple data encryption (XOR ciphers), error-checking and parity bits, swapping two variables without a temporary variable, toggling bits/flags in low-level programming, and as a fundamental logic gate in digital circuit design. Because it's easy to get confused between XOR, OR, and AND when working by hand, this tool is also useful simply to double-check your own bitwise arithmetic before using it in code or coursework.
How bitwise XOR works
XOR compares two binary numbers bit by bit. For each pair of corresponding bits, the XOR result bit is 1 if exactly one of the two bits is 1, and 0 if the bits are the same (both 0 or both 1). For example, comparing the binary numbers 1100 (12) and 1010 (10) bit by bit: 1โ1=0, 1โ0=1, 0โ1=1, 0โ0=0, giving 0110, which is 6 in decimal. This calculator converts your decimal inputs to binary automatically (or accepts binary directly), pads them to equal length, and applies this bit-by-bit comparison.
The XOR truth table
Because XOR only has two possible input bits (0 or 1), its entire behaviour can be summarised in a short truth table: 0 XOR 0 = 0, 0 XOR 1 = 1, 1 XOR 0 = 1, and 1 XOR 1 = 0. Notice the pattern: the result is 1 exactly when the two inputs are different, which is where the name 'exclusive OR' comes from โ unlike plain OR, XOR excludes the case where both inputs are 1.
Frequently asked questions
Plain OR returns 1 if at least one input is 1 (including when both are 1). XOR returns 1 only when the inputs differ โ it returns 0 when both inputs are 1, which is the key difference.
Convert both numbers to binary, line up the bits, and for each column write 1 if the two bits differ and 0 if they're the same. Then convert the resulting binary string back to decimal if needed.
XOR is reversible: applying the same key twice with XOR returns the original value (A XOR B XOR B = A). This makes it a simple, fast building block for basic ciphers and checksums.
Both equal 0, because XOR only returns 1 when the two input bits are different from each other.