Self Complementing Codes

Self Complementing Codes

Self-complementing binary codes are those whose members complement on themselves. For a binary code to become a self-complementing code, the following two conditions must be satisfied:

1.    The complement of a binary number should be obtained from that number by replacing 1’s with 0’s and 0’s with 1’s (already stated procedure).
2.    The sum of the binary number and its complement should be equal to decimal 9.

The following example will illustrate this procedure.

The Excess-3 (Xs-3) Code

Let us now consider the excess-3 (Xs-3) binary coding system.  An Xs-3 equivalent of a given binary number is obtained using the following steps:

1.      Find the decimal equivalent of the given binary number.
2.      Add +3 to the decimal equivalent obtained in 1.
3.      Convert the newly obtained decimal number back to binary number to get the desired Xs-3 equivalent.

Following the steps given above, we draw Table 1.24, which shows the binary and Xs-3 equivalents.

Table Xs-3 binary codes

Binary numbers
Decimal equivalent
Decimal +3
Xs-3 equivalent
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
0
1
2
3
4
5
6
7
8
9
3
4
5
6
7
8
9
10
11
12
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100

Example 23: Prove that Xs-3 code is a self-complementing code.

Solution: Consider the Xs-3 number 0101. From Table 1.24, we obtain 0101 ≡ decimal 2. Its complement (by changing 1s to 0s and vice versa) is 1010. From Table 1.24, we find that decimal equivalent of 1010 is 7. Now adding the decimal equivalents of 0101 (≡2) and 1010 (≡7) yields decimal 9.  It can be seen that all the numbers in Xs-3 code obeys this condition. Then by condition 2 (see Section 1.14), Xs-3 code is a self-complementing code.

The 8-4-2-1 Binary Weighted (or, Conventional) Code

In the decimal number system, we know that (123)10 = 1× 10 + 2× 1021 +3× 100, where 10, 101, and 100 are the positional weights (or simply, weights) of the coefficients 1, 2, and 3, respectively. In the same fashion, we may express (1011)2 = 1× 2 + 0× 2 +1× 2+1× 20. The weights of 1, 0, 1, and 1 are, respectively, 2 = 8, 2 = 4, 2= 2, and 20 = 1. Since the positional weights are 8, 4, 2, and 1, we call the conventional binary system as the 8-4-2-1 binary number system also. We multiply the bits in a given binary number with their respective weights and add them to yield their decimal equivalent. For example, we have seen that 1011 = 1× 8 + 0× 4 +1× 2­+1× 1 = (11)10. In Example 24, we prove that the 8-4-2-1 code is not a self-complementing code.

Example 24: Prove that the conventional binary code is not a self-complementing code.

Solution: To illustrate this, consider binary number 1011, whose 1’s complement is 0100. We know that (1011)2 º (11)10 and (0100)2 º (4)10. Now, the sum of (11)10 + (4)10 = (15)10, and not (9)10. Therefore, we conclude that 1011 and 0100 are not complementary numbers and hence, the conventional binary code is not a self-complementing code.

The 2-4-2-1 Binary Weighted Code

Example 25: Prove that 2-4-2-1 code is a self-complementing code.

Solution: The basic members of this family are given in Table 1.25. The bits in each of the binary numbers given in the first column may be multiplied with their respective weights to get the equivalent decimal in the second column. For example, number 1011 has its equivalent decimal as 5. This is obtained as follows:

                                                      1011 = 1× 2 + 0×4+1× 2 +1= 2 + 2 + 1 = 5

All the other decimal equivalents can be similarly obtained.  

Table: The 2-4-2-1 code 

2-4-2-1 code
Decimal equivalent
0000
0001
0010
0011
0100
1011
1100
1101
1110
1111
0
1
2
3
4
5
6
7
8
9

Now, consider number (1011)2 ≡ (5)10 in Table 1.25 again. The complement of 1011 is 0100. From Table 1.25, we obtain the decimal equivalent of 0100 as 4. Adding 5 and 4 yields 9. Hence, we conclude that the 2-4-2-1 code exhibits the necessary property of self-complementing codes. In similar fashions, we can prove that all the other numbers of this coding scheme also exhibit this property. Therefore we conclude that the 2-4-2-1 code is a self-complementing code.