XOR Calculator
Compare two integers bit by bit and see their exclusive-OR result in binary, decimal, and octal form.
Workbook ready for the demonstration values.
Input data
Results
80 XOR 100 using an 8-bit word
Bit-by-bit comparison
| Bit position | Number 1 bit | Number 2 bit | XOR bit | Relationship |
|---|---|---|---|---|
| 7 (most significant) | 0 | 0 | 0 | Same → 0 |
| 6 | 1 | 1 | 0 | Same → 0 |
| 5 | 0 | 1 | 1 | Different → 1 |
| 4 | 1 | 0 | 1 | Different → 1 |
| 3 | 0 | 0 | 0 | Same → 0 |
| 2 | 0 | 1 | 1 | Different → 1 |
| 1 | 0 | 0 | 0 | Same → 0 |
| 0 (least significant) | 0 | 0 | 0 | Same → 0 |
How to use the XOR calculator
What this calculator does
This calculator performs a fixed-width bitwise exclusive OR between two integers. It compares the corresponding bits of Number 1 and Number 2; a result bit is 1 only when the two input bits differ. The tool reports the same bit pattern in binary, signed decimal, octal, and hexadecimal notation and displays every comparison row. It is useful for checking code, logic-gate exercises, masks, parity reasoning, and two's-complement representations. It does not evaluate Boolean expressions with more than two operands, prove cryptographic security, or simulate the electrical timing of a physical gate.
When to use it
- Verify the output of a programming expression such as
a ^ bbefore putting it into production code. - Check an XOR truth-table exercise or inspect which bit positions differ between two words.
- Translate one XOR result across binary, decimal, octal, and hexadecimal notation.
- Explore how signed decimal inputs are encoded using a fixed-width two's-complement bit pattern.
How to calculate
- The calculator opens with a complete demonstration: an 8-bit representation, Decimal datatype, Number 1 = 80, and Number 2 = 100. Its workbook is validated during initialization, so Download Excel is immediately available.
- Choose Binary representation. Four, eight, sixteen, and thirty-two bits are supported. The width controls the signed decimal range and the number of rows in the bit comparison.
- Choose Datatype. Binary accepts 0 and 1 with an optional
0bprefix; Decimal accepts a signed whole number without commas or scientific notation; Octal accepts digits 0 through 7 with an optional0oprefix. Changing datatype converts valid current values rather than merely relabeling them. - Replace Number 1 and Number 2. Results update live. Read the main binary answer, then use the secondary result cards and the bit-by-bit table to inspect the same operation from different angles.
- Select Download Excel to export the current validated model, including inputs, outputs, bit rows, and the XOR truth table. Reset clears the demonstration values and results; export is then disabled until both required numbers are complete and valid again.
Input guide
Binary representation is a required select control. It determines the word size in bits. For example, 8 bits permits signed decimal values from – 128 through 127, while the underlying bit pattern ranges from 00000000 through 11111111. A larger width preserves more high-order bits; a smaller width can make an otherwise valid decimal input out of range. Do not assume changing the width mathematically “rescales” a value.
Datatype is required and controls how both number fields are parsed and displayed. Binary and octal entries represent an unsigned bit pattern inside the selected word, while decimal entries use the signed two's-complement range. For example, binary 11111111 in an 8-bit word corresponds to decimal – 1. A common mistake is entering a decimal digit string while Binary is selected or entering 1e3; unsupported or ambiguous formats are rejected instead of silently rewritten.
Number 1 and Number 2 are required integers. With the startup settings, realistic entries are 80 and 100. Raising or lowering either number changes whichever bit positions change in its fixed-width representation, so the XOR result is not generally monotonic. Decimal values must stay within the selected signed range; binary values may contain no more than the selected number of bits; octal values must fit inside the same word.
Output guide
Binary XOR result is the exact fixed-width result bit pattern. Decimal result interprets that pattern as a signed two's-complement integer. Octal result and Hexadecimal check are alternative representations of the same unsigned pattern. Differing bits equals the number of XOR output bits set to 1, while Matching bits counts equal input pairs. Result set bits is the population count of the output and therefore equals Differing bits. A zero result means every corresponding pair matched; a result with every bit set means the two input patterns were exact complements.
The summary pills repeat the current Width, Input datatype, differing-bit count, and signed decimal Result. In the table, Bit position runs from the most significant to the least significant bit; the two input columns show the source bits; XOR bit shows the resulting 0 or 1; and Relationship states whether the pair was the same or different. These values are exact identities, not statistical estimates.
Worked example
With the demonstration values, 80 is 01010000 and 100 is 01100100 in 8-bit binary. Compare them position by position:
The output 00110100 has three 1s, so the inputs differ at three bit positions and match at five. Interpreting that output pattern gives decimal 52, octal 64, and hexadecimal 0x34. Those are the exact first-open results shown above and written into the startup workbook.
Learn more
The NIST definition of exclusive OR describes XOR as bitwise modulo-2 arithmetic without carry. For programming behavior, the MDN reference for the bitwise XOR operator explains when a result bit becomes 1. A broader treatment of positional notation is available in LibreTexts' binary number representation chapter.
How XOR logic works
XOR is sometimes described as “one or the other, but not both.” For a single pair of bits, 0 XOR 0 is 0, 0 XOR 1 is 1, 1 XOR 0 is 1, and 1 XOR 1 is 0. Applying that rule independently to every position produces a bitwise XOR. Because no carry is propagated between positions, XOR also behaves like addition modulo 2 for each bit.
| Input A | Input B | A XOR B | Meaning |
|---|---|---|---|
| 0 | 0 | 0 | Same inputs |
| 0 | 1 | 1 | Different inputs |
| 1 | 0 | 1 | Different inputs |
| 1 | 1 | 0 | Same inputs |
Signed values and fixed width
A negative decimal value is converted to a two's-complement bit pattern before the XOR operation. Width matters because the same mathematical integer has different padded representations at different widths. For example, – 1 is 1111 at 4 bits, 11111111 at 8 bits, and thirty-two 1s at 32 bits. The calculator keeps the selected width throughout parsing, comparison, display, and workbook export.