# XOR Calculator

Created by Purnima Singh, PhD
Reviewed by Steven Wooding
Last updated: Mar 11, 2022

Use the XOR calculator to perform a bitwise XOR operation on two numbers. You can input data in binary, decimal, or octal representations.

• What is XOR operation?
• How to calculate the XOR of two numbers?
• What are the applications of XOR logic operation?

## What is the XOR operation?

XOR or eXclusive OR is a logical operation that compares the input values (bits) and generates the output value (bit). The exclusive OR logic is very simple. If the input values are the same, the output is 0 (or false). If the input values are different, the result is 1 (or true).

There are various symbols used for the XOR operation, for example, ⊕, ^, XOR, or EXOR. The Boolean expression for the XOR operation is:

• $A \cdot \overline{B} + \overline{A} \cdot B = Y$; or

• $A\oplus B = Y$

To implement a binary XOR operation in electronic circuits, we use XOR gates. In the next section, we will see what an XOR gate is.

## The XOR gate

The XOR (or exclusive-OR) gate is a combination of OR, AND, and NOT gates (see figure 1). The output of an XOR logic gate is high (1) when either of the inputs is high (1). If both the inputs are high (1) or both the inputs are low (0), the output is low (0).

Figure 2 shows the logic symbol of the XOR gate.

## Exclusive OR truth table

The following table shows the truth table of binary XOR (exclusive OR) operation between two inputs A and B (A XOR B).

Table: Truth table for XOR operation.

A

B

Output (Y)

0

0

0

0

1

1

1

0

1

1

1

0

You can see from the truth table that the XOR operation is binary addition if we neglect to take into account the carries. Therefore, the XOR operation is also called mod-2 addition.

In the given truth table, we have only considered XOR operation on two single bits. However, we need to perform a bitwise XOR operation when dealing with bit vectors (e.g., a byte).

## How to calculate the XOR of two numbers?

To understand the bitwise eXclusive OR logic operation, let us calculate the XOR of two numbers, 80 and 100.

1. First we will express both the numbers into the binary representation:

• The 8-bit binary representation of 80 is 0101 0000.
• The 8-bit binary representation of 100 is 0110 0100.

It is imperative that both the numbers are of equal bit length.

2. Now, we will find the XOR of each pair of corresponding bits, from the first to the last, using the rule:

• If both bits are the same, i.e., 1 (or 0), the output bit is 0.
• If both bits are different, the output is 1.
3. For example, the first bit pair is 0⊕0, the output bit will be 0. Similarly, we can determine the output bit for all the pairs.

XOR operation:

0101 0000

0110 0100

=

0011 0100

1. Hence, the result of XOR operation on 80 and 100 is 0011 0100.

If you are interested in more complex logical operations like bit shift, we recommend checking out the bit shift calculator.

## How to use the XOR calculator?

Now let us see how we can use the XOR calculator to calculate the XOR of two numbers:

1. Using the drop-down menu, choose the number of bits in the binary representation. We will choose 8 bits, as it allows the decimal numbers between -128 and 127.

2. Choose the input data type as decimal. The bitwise XOR calculator allows you to enter numbers in the binary, decimal, and octal systems.

3. Now enter the numbers 80 and 100 in the fields Number 1 and Number 2, respectively.

4. The bitwise XOR calculator will give the result of XOR operation in the binary (0011 0100), decimal (52), and octal systems (64).

## Applications of XOR logic operation

The XOR logic operation is widely used in digital electronic circuits and computer programming. Some of the common applications of XOR logic are:

• Cryptography: XOR logic is extensively implemented in encryption methods.

• Error detection: The XOR logic gives the output 0 if an even number of input bits are 1 (even parity), and it gives the result 1 if an odd number of input bits are 1 (odd parity). Therefore, we use the XOR logic to detect the parity of transmitted data. This technic helps to determine if the data has been corrupted while sending digital information.

• RAID data protection: By arranging the hard drives in such a way that one of the drives contains the XOR of all the others, RAID (redundant arrays of inexpensive disks) systems restore corrupted drives.

• Adder circuit: XOR logic gates are widely used in computer circuits to perform basic arithmetic operations like addition and subtraction.

## FAQ

### What does bitwise XOR mean?

In bitwise XOR operation on two binary numbers, we compare a pair of individual bits in corresponding positions. The output bit is 1 if only one of the input bits is 1. Otherwise, it is zero.

### How do I find the XOR of two numbers?

To find the XOR of two numbers, follow these instructions:

1. Convert the numbers into the binary representation.
2. Compare the corresponding bits of the two numbers.
3. If only one of the input bits is true (1), the output is true (1). Otherwise, the output is false (0).

### How do I find the XOR of three binary numbers?

To find the XOR of three or more binary numbers, compare their corresponding bits according to the given rule:

1. If an odd number of input bits is true (1), the XOR output is true (1).
2. If an even number of input bits is true (1), the XOR output is false (0).

### What is the truth table for 3 input XOR operation?

The truth table for 3-input XOR operation, i.e., A XOR B XOR C is given below:

A

B

C

A XOR B XOR C

1

1

1

1

1

1

0

0

1

0

1

0

1

0

0

1

0

1

1

0

0

1

0

1

0

0

1

1

0

0

0

0

Purnima Singh, PhD
Input data
Binary representation
8-bit
Datatype
Decimal
You can enter decimal numbers between -128 and 127.
Number 1
Number 2
People also viewed…

### BMR - Harris-Benedict equation

Harris-Benedict calculator uses one of the three most popular BMR formulas. Knowing your BMR (basal metabolic weight) may help you make important decisions about your diet and lifestyle.

### Car vs. Bike

Everyone knows that biking is awesome, but only this Car vs. Bike Calculator turns biking hours into trees! 🌳

### Comparing fractions

Our comparing fractions calculator can compare any two fractions in an instant.

### Fundamental counting principle

The fundamental counting principle calculator will help you find out how many options you have for choosing up to ten characteristics of whatever it is you're dealing with.