User Rating 0.0 ā˜…ā˜…ā˜…ā˜…ā˜…
Total Usage 0 times
0b
0 bits Dec: 0
XOR
0b
0 bits Dec: 0
Quick presets:
Is this tool helpful?

Your feedback helps us improve.

ā˜… ā˜… ā˜… ā˜… ā˜…

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.

binary xor calculator bitwise xor binary calculator xor operation binary arithmetic bit manipulation

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.

R = A āŠ• B

For each bit position i from 0 to n āˆ’ 1:

Ri = Ai āŠ• Bi = (Ai ∧ ¬Bi) ∨ (¬Ai ∧ Bi)

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:

dH(A, B) = popcount(A āŠ• B)

Where popcount counts the number of 1-bits in the result. This metric is used in error-correcting codes and similarity measures.

Reference Data

ABA āŠ• BDescription
000Both bits equal (zero) → result 0
011Bits differ → result 1
101Bits differ → result 1
110Both bits equal (one) → result 0
Common XOR Properties
CommutativeA āŠ• B = B āŠ• A
Associative(A āŠ• B) āŠ• C = A āŠ• (B āŠ• C)
IdentityA āŠ• 0 = A
Self-InverseA āŠ• A = 0
Bitwise NOT via XORA āŠ• 1...1 = ¬A
XOR Applications
Swap without tempa = a āŠ• b; b = a āŠ• b; a = a āŠ• b
Parity checkXOR all bits: result 1 → odd parity
CRC checksumsPolynomial division via repeated XOR
One-time padPlaintext āŠ• Key = Ciphertext
RAID 5 parityDisk1 āŠ• Disk2 āŠ• … = Parity
Gray code conversionGi = Bi āŠ• Bi+1
Find unique elementXOR all elements in array; duplicates cancel
Hamming distancepopcount(A āŠ• B) counts differing bits

Frequently Asked Questions

AND produces 1 only when both bits are 1. OR produces 1 when at least one bit is 1. XOR produces 1 exclusively when the bits differ. In Boolean algebra: A āŠ• B = (A ∧ ¬B) ∨ (¬A ∧ B). This means XOR can be decomposed into AND, OR, and NOT gates, requiring 5 gates in canonical form.
XOR is its own inverse: A āŠ• K āŠ• K = A. This means encryption and decryption use the same operation with the same key. In a one-time pad, if the key is truly random, as long as the message, and never reused, the cipher is mathematically proven unbreakable (Shannon, 1949). Stream ciphers like RC4 and ChaCha20 generate pseudo-random keystreams that are XORed with plaintext.
Any value XORed with itself produces zero: A āŠ• A = 0. This self-inverse property is exploited in algorithms to find the unique element in an array where all other elements appear twice. XOR all elements together; duplicates cancel to zero, leaving only the unique value. Time complexity is O(n) with O(1) space.
No. This tool treats all inputs as unsigned binary integers in the range 0 to 232 āˆ’ 1 (4,294,967,295). JavaScript's bitwise XOR operator internally converts operands to 32-bit signed integers, but the calculator displays results as unsigned. If you need signed interpretation, the most significant bit (bit 31) acts as the sign bit in two's complement, and you must manually interpret the output.
The Hamming distance between two binary strings equals the number of bit positions where they differ. Compute A āŠ• B, then count the 1-bits (population count) of the result. For example, 1011 āŠ• 1101 = 0110, which has 2 set bits, so the Hamming distance is 2. This metric is critical in error-correcting codes (e.g., Hamming codes can correct single-bit errors when minimum distance ≄ 3).
RAID 5 stripes data across n disks and stores a parity block computed as the XOR of all data blocks: P = D1 āŠ• D2 āŠ• … āŠ• Dnāˆ’1. If any single disk fails, its data is recovered by XORing the remaining disks with the parity: Dfailed = P āŠ• D1 āŠ• … (excluding the failed disk). This works because XOR is associative, commutative, and self-inverse.