Omni Calculator logo

Use the XOR calculator to perform a bitwise XOR operation on two numbers. You can input data in binary, decimal, or octal representations. If you want to perform bitwise AND or bitwise OR operations, our bitwise calculator may be the right tool for you.

Continue reading to learn:

  • 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:

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

  • AB=YA\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).

An exclusive OR gate.
Fig. 1: An exclusive OR gate.

Figure 2 shows the logic symbol of the XOR gate.

Logic symbol of XOR Gate.
Fig. 2: Logic symbol of XOR Gate.

To know more about other logic gates, check out the logic gate calculator.

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
Check out 13 similar binary calculators 1️0️
ANDBinary additionBinary division… 10 more
People also viewed…

Grams to cups

The grams to cups converter converts between cups and grams. You can choose between 20 different popular kitchen ingredients or directly type in the product density.

Podcasts

Do you feel like you could be doing something more productive or educational while on a bus? Or while cleaning the house? Well, why don't you dive into the rich world of podcasts! With this podcast calculator, we'll work out just how many great interviews or fascinating stories you can go through by reclaiming your 'dead time'!

Sector area

Sector area calculator can find the sector area of a circle in the blink of an eye.

Trigonometric functions

The trigonometric functions calculator will find the sine, cosine, tangent, cotangent, secant, and cosecant of any chosen angle. Enter the angle value in degrees or radians, and see all essential trigonometric functions.
Copyright by Omni Calculator sp. z o.o.
Privacy, Cookies & Terms of Service