Advertisement

XOR calculator

Find the positions where two patterns differ. XOR is useful for toggling flags, comparing bit strings and following a binary parity calculation.

Calculator

Binary result
00000110
Octal result
6
Unsigned decimal
6
Signed decimal (two's complement)
6
One operation per bit
PositionABResult
7000
6000
5000
4000
3110
2101
1011
0000

Advertisement

How this calculator works

XOR toggles a bit wherever the second operand is 1. Applying the same XOR mask twice restores the original pattern. Inputs must fit the selected width. Short binary patterns receive leading zeros. Decimal negatives use two's complement and must be at least -2^(n-1). The signed output interprets the top bit as a negative place value; the unsigned output reads the same pattern as nonnegative.

Formula

At each position, a XOR b = (a + b) mod 2. Equal input bits produce 0; different bits produce 1.

Worked example

In four bits, 1100 XOR 1010 = 0110, or 12 XOR 10 = 6 in decimal.

Advertisement

Frequently asked questions

How is XOR different from ordinary arithmetic?

It acts separately on each bit position without carrying between columns. The table shows the input pair and output bit for every position.

What happens at the limits?

A pattern XOR itself is zero. Unlike OR, a pair of 1 bits cancels rather than remaining set.

Can I use more than 32 bits?

Yes. Choose a preset through 64 bits or a custom width from 1 to 256. Text entry preserves every digit, including leading zeros.

Why can signed and unsigned results differ?

They interpret one stored pattern differently. If its highest bit is 1, two's complement subtracts 2^n from the unsigned value.

Sources

Advertisement