XOR Calculator - Exclusive OR Logic & Bitwise Operations

Calculate XOR (Exclusive OR) for boolean values, binary sequences, and decimal integers with step-by-step explanations and truth tables.

Select an operation type, enter your two values, and click Calculate to see the XOR result with optional truth table and step breakdown.

XOR Calculator - Exclusive OR Logic & Bitwise Operations
Calculate XOR (Exclusive OR) for boolean values, binary sequences, and decimal integers with step-by-step explanations and truth tables.

XOR two boolean values (0/1 or true/false). Returns true when exactly one input is true.

About the XOR Calculator

XOR, short for Exclusive OR, is one of the fundamental logic operations in Boolean algebra and digital electronics. Unlike the regular OR operation which returns true when at least one input is true, XOR returns true only when exactly one of its two inputs is true — never when both are true or both are false. This "exclusive" behavior makes XOR uniquely valuable in a wide range of computing and mathematics contexts. At its simplest level, Boolean XOR is a binary logic gate. If you feed it two inputs — each either 0 (false) or 1 (true) — the output is 1 only when the inputs differ. The complete truth table is: 0 XOR 0 = 0, 0 XOR 1 = 1, 1 XOR 0 = 1, and 1 XOR 1 = 0. This property is directly analogous to the statement "either one but not both." In everyday language, "I'll have cake or pie (but not both)" is an XOR statement. Binary XOR extends the Boolean case across entire bit strings. Each corresponding pair of bits from the two input sequences is XOR'd independently to produce the output bit. For example, 1010 XOR 1100 = 0110 because the first bits (1 and 1) produce 0, the second bits (0 and 1) produce 1, the third bits (1 and 0) produce 1, and the fourth bits (0 and 0) produce 0. This operation is fundamental in digital communication for error detection, in RAID storage systems for parity calculation, and in cryptography as a key component of stream ciphers. Bitwise XOR operates on the full binary representation of decimal integers simultaneously. Modern processors implement bitwise XOR as a single-clock instruction, making it extremely fast. Programmers use bitwise XOR for many clever tricks: swapping two integers without a temporary variable (a ^= b; b ^= a; a ^= b;), toggling specific bits in a bitmask, detecting the single unique number in an array of duplicates, and computing checksums. The property that a XOR a = 0 (any value XOR itself is zero) and a XOR 0 = a (any value XOR zero is itself) underpin many of these applications. In cryptography, XOR is the backbone of the one-time pad — the only provably unbreakable encryption scheme when the key is truly random and used only once. Every bit of the message is XOR'd with a corresponding bit of the key. Decryption is identical: XOR the ciphertext with the same key to recover the original. This works because XOR is its own inverse: (a XOR k) XOR k = a. Stream ciphers and block cipher modes like CTR and OFB leverage this property to turn a block cipher into a keystream-based system. The XOR calculator handles all three variants — Boolean, Binary, and Bitwise — in one place. Enter your values, choose the operation mode that fits your needs, and optionally enable the truth table or step-by-step breakdown to understand exactly how the result is derived.

XOR Calculator Examples

Common XOR operations showing Boolean, Binary, and Bitwise modes with real values.

InputResultExplanation
Boolean: true XOR falsetrueInputs differ, so XOR returns true. 1 XOR 0 = 1.
Boolean: true XOR truefalseBoth inputs are the same, so XOR returns false. 1 XOR 1 = 0.
Binary: 1010 XOR 11000110Bit-by-bit XOR: 1^1=0, 0^1=1, 1^0=1, 0^0=0. Result is 0110 (decimal 6).
Bitwise: 12 XOR 10612 in binary is 1100, 10 is 1010. XOR gives 0110 = decimal 6.

How to Use the XOR Calculator

  1. Choose the operation type: Boolean for true/false values, Binary for bit sequences, or Bitwise for decimal integers.
  2. Enter the first value (A) in the appropriate format — 0/1/true/false for Boolean, a bit string like 1010 for Binary, or a decimal integer for Bitwise.
  3. Enter the second value (B) in the same format as the first.
  4. Optionally enable Show Truth Table to see all four input combinations, or Show Steps to see the XOR derivation explained bit by bit.
  5. Click Calculate XOR to compute the result. Click Reset to clear all fields and start over.

XOR Calculator FAQ

What does XOR mean?
XOR stands for Exclusive OR. It is a logical operation that returns true (1) when exactly one of its two inputs is true, and false (0) when both are the same. The "exclusive" part distinguishes it from regular OR, which also returns true when both inputs are true.
How is XOR different from OR?
Regular OR returns true if one OR both inputs are true. XOR returns true only if one input is true and the other is false — it excludes the case where both are true. The truth table rows 0-OR-0=0 and 1-OR-1=1 are the same; the difference appears at 1 XOR 1, which is 0 while 1 OR 1 is 1.
Why is XOR important in cryptography?
XOR is its own inverse: (a XOR k) XOR k = a for any values a and k. This means you can encrypt by XOR-ing with a key and decrypt by XOR-ing with the same key again. The one-time pad, the only provably unbreakable cipher, is based entirely on XOR. Stream ciphers and many block cipher modes also rely on XOR to mix key material with plaintext.
How do I XOR binary numbers of different lengths?
Zero-pad the shorter sequence on the left until both sequences have the same length, then XOR each corresponding pair of bits. For example, 110 XOR 1010 becomes 0110 XOR 1010 = 1100. This calculator handles the zero-padding automatically.
What is a practical use of bitwise XOR in programming?
Bitwise XOR is commonly used to swap two variables without a temporary: a ^= b; b ^= a; a ^= b;. It is also used to toggle specific bits in a flag register, to find the single non-duplicate element in an array (XOR all elements; pairs cancel to 0), and to compute fast checksums and hash mixing.
Can XOR be used on more than two inputs?
Yes. Multi-input XOR is simply the pairwise XOR applied sequentially. The result is 1 (true) when an odd number of inputs are 1, and 0 (false) when an even number are 1. This property is used in RAID-5 parity calculations, where the parity of multiple data disks is the XOR of all of them.