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
0
3
0011
0001
1
4
0100
0010
2
5
0101
0011
3
6
0110
0100
4
7
0111
0101
5
8
1000
0110
6
9
1001
0111
7
10
1010
1000
8
11
1011
1001
9
12
1100

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

Solution: Consider the Xs-3 number 0101. From Table, we obtain 0101 ≡ decimal 2. Its complement (by changing 1s to 0s and vice versa) is 1010. From Table, 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, 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 2, we prove that the 8-4-2-1 code is not a self-complementing code.

Example 2: 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. 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
0
0001
1
0010
2
0011
3
0100
4
1011
5
1100
6
1101
7
1110
8
1111
9

Now, consider number (1011)2 ≡ (5)10 in Table 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.


Sreejith Hrishikesan

Sreejith Hrishikesan is a ME post graduate and has been worked as an Assistant Professor in Electronics Department in KMP College of Engineering, Ernakulam. For Assignments and Projects, Whatsapp on 8289838099.

2 Comments

Previous Post Next Post