Previous | ToC | Next Labs: Cryptography. Part 1. Math Alive

Parity Addition


There is another additive operation on binary numbers that is very useful. It is called "parity" addition or "XOR" (The word XOR originated from exclusive-OR). We still call it addition because this operation has many properties in common with standard decimal (or binary) addition: it is commutative and associative, and "adding" zero to a number doesn't change the number. Parity addition is similar to binary addition, except that there is never a carry.
To distinguish them we will denote the parity addition by oplus. For parity addition we have:

    0 oplus 0 = 0
    0 oplus 1 = 1
    1 oplus 0 = 1
    1 oplus 1 = 0 .

We can formulate the rule: parity adding two identical digits gives 0, while parity adding two different digits gives 1. (Note: many software developers have adopted the word "XOR" in their language. For example: Tomorrow I will go to the movie xor to the park. This means that I will go to exactly one of them, not both.)
To distinguish this addition from binary addition people use a special symbol for parity addition or each time they say explicitly that they use parity addition. (The default addition, or what is meant by addition if no additional qualifier is given, for binary numbers is the addition we've learned on preceding pages.)

Note. When we parity add two binary numbers of different length, we add leading zeros to the smaller number, so both numbers would become the same length. Sometimes, we say that we parity add binary strings.

Example. Suppose we would like to parity add the two binary numbers 10 and 11. We can start from the last digit or the first digits - this doesn't matter as there is no carry. We add each column separately. For the last column, adding 0 and 1, we get 1 (no carry). That means the last digit of the answer will be 1. Then we move one digit to the left: adding 1 and 1 we get 0. Hence, the answer is 01. Note that leading zero gives us an important information: that the digits we added in that column were the same; hence, when we parity add numbers we keep leading zeros in the answer.

Try and solve the examples from the previous page using Parity Addition:

Practice
Parity Addition


Previous | ToC | Next Last Modified: August 2008