One of the things that makes binary so useful in electronics is that it’s very efficient at handling special operations called logical operations. Logical operations compare two binary bits and render a third binary bit as a result. There are 16 possible logical operations. For now, let’s focus on three of them: AND, OR, and XOR.

The following list summarizes these three basic logical operations:

• AND: An AND operation compares two binary values. If both values are 1, the result of the AND operation is 1. If one value is 0 or both of the values are 0, the result is 0.

• OR: An OR operation compares two binary values. If at least one of the values is 1, the result of the OR operation is 1. If both values are 0, the result is 0.

• XOR: An XOR operation compares two binary values. If exactly one of them is 1, the result is 1. If both values are 0 or if both values are 1, the result is 0.

First Value Second Value AND OR XOR
0 0 0 0 0
0 1 0 1 1
1 0 0 1 1
1 1 1 1 0

You can apply logical operations to binary numbers that have more than one binary digit by applying the operation one bit at a time. The easiest way to do this manually is to line the two binary numbers on top of one another and then write the result of the operation below each binary digit. The following example shows how you’d calculate 10010100 AND 11011101:

As you can see, the result is 10010100.