Which of the following binary codes for decimal digits are self-complementing? (a) 8421 code (b) 2421 code (c) excess-3 code (d) excess-3 gray code Choose the correct option:
(b) and (c)
A binary code is considered self-complementing if the binary representation of the 9's complement of a decimal digit can be obtained by simply complementing each bit of the binary representation of the digit itself. For a 4-bit code representing a decimal digit \(D\) as \(b_3 b_2 b_1 b_0\), the code for \(9-D\) must be \(\bar{b_3} \bar{b_2} \bar{b_1} \bar{b_0}\). This property is useful in digital systems for simplifying subtraction operations.
Let's examine the given binary codes for decimal digits to determine which ones are self-complementing.
The 8421 code is a weighted code where the weights are 8, 4, 2, and 1 from left to right. The sum of the weights is \(8+4+2+1 = 15\), which is not 9. Let's check a few decimal digits and their 9's complements:
| Decimal Digit | 8421 Code | 9's Complement (Decimal) | 8421 Code for 9's Complement | Bitwise Complement of Original 8421 Code | Self-Complementing? |
|---|---|---|---|---|---|
| 0 | 0000 | 9 | 1001 | 1111 | No |
| 1 | 0001 | 8 | 1000 | 1110 | No |
| 4 | 0100 | 5 | 0101 | 1011 | No |
As seen in the table, the bitwise complement of the 8421 code for a digit does not match the 8421 code for its 9's complement. Therefore, the 8421 code is not self-complementing.
The 2421 code is a weighted code with weights 2, 4, 2, and 1. The sum of the weights is \(2+4+2+1 = 9\). This is a characteristic property of many self-complementing weighted codes. Let's check its behavior:
| Decimal Digit | 2421 Code | 9's Complement (Decimal) | 2421 Code for 9's Complement | Bitwise Complement of Original 2421 Code | Self-Complementing? |
|---|---|---|---|---|---|
| 0 | 0000 | 9 | 1111 | 1111 | Yes |
| 1 | 0001 | 8 | 1110 | 1110 | Yes |
| 4 | 0100 | 5 | 1011 | 1011 | Yes |
| 5 | 1011 | 4 | 0100 | 0100 | Yes |
| 9 | 1111 | 0 | 0000 | 0000 | Yes |
In the 2421 code, the bitwise complement of the code for a digit matches the code for its 9's complement. Thus, the 2421 code is self-complementing.
The Excess-3 code is a non-weighted code. It is derived by adding 3 (0011 in binary) to the 8421 BCD representation of the decimal digit. Let's check if it's self-complementing:
| Decimal Digit | 8421 BCD | Excess-3 Code (BCD + 0011) | 9's Complement (Decimal) | Excess-3 Code for 9's Complement | Bitwise Complement of Original Excess-3 Code | Self-Complementing? |
|---|---|---|---|---|---|---|
| 0 | 0000 | 0011 | 9 | 1001 + 0011 = 1100 | 1100 | Yes |
| 1 | 0001 | 0100 | 8 | 1000 + 0011 = 1011 | 1011 | Yes |
| 4 | 0100 | 0111 | 5 | 0101 + 0011 = 1000 | 1000 | Yes |
| 5 | 0101 | 1000 | 4 | 0100 + 0011 = 0111 | 0111 | Yes |
| 9 | 1001 | 1100 | 0 | 0000 + 0011 = 0011 | 0011 | Yes |
For the Excess-3 code, the bitwise complement of the code for any digit is indeed the Excess-3 code for its 9's complement. Therefore, the Excess-3 code is self-complementing.
The Excess-3 Gray code is obtained by converting the Excess-3 code into a Gray code. A Gray code is characterized by having only one bit change between successive numbers. Let's see if this process preserves the self-complementing property:
| Decimal Digit | Excess-3 Code | Excess-3 Gray Code | 9's Complement (Decimal) | Excess-3 Code for 9's Complement | Excess-3 Gray Code for 9's Complement | Bitwise Complement of Original Excess-3 Gray Code | Self-Complementing? |
|---|---|---|---|---|---|---|---|
| 0 | 0011 | 0010 | 9 | 1100 | 1010 | 1101 | No |
| 1 | 0100 | 0100 | 8 | 1011 | 1011 | 1011 | Yes (coincidence for this pair?) |
| 2 | 0101 | 0111 | 7 | 1010 | 1110 | 1000 | No |
| 3 | 0110 | 0110 | 6 | 1001 | 1101 | 1001 | No |
| 4 | 0111 | 0100 | 5 | 1000 | 1100 | 1011 | No |
As illustrated, the bitwise complement of the Excess-3 Gray code for a digit does not consistently match the Excess-3 Gray code for its 9's complement. Therefore, the Excess-3 Gray code is not self-complementing.
Based on the analysis, the binary codes that are self-complementing for decimal digits among the given options are:
| Code Type | Weighted? | Self-Complementing? | Example (Decimal 4) | Notes |
|---|---|---|---|---|
| 8421 BCD | Yes (8,4,2,1) | No | 0100 | Most common BCD |
| 2421 code | Yes (2,4,2,1) | Yes | 0100 or 1010 (depends on representation) | Sum of weights = 9 |
| Excess-3 code | No | Yes | 0111 | Derived from 8421 BCD + 3 |
| Excess-3 Gray code | No | No | 0100 | Based on Excess-3 converted to Gray |
Binary codes are fundamental to digital systems. They allow decimal numbers, characters, and instructions to be represented using only two digits, 0 and 1.
Which of the following pairs of octal and binary numbers are NOT equal?
The greatest negative number which can be stored in a 8-bit register using 2's complement arithmetic is
Which of the following codes is also known as reflected binary code?
What is the octal equivalent of (F3B1)16?
The 1's complement of binary number 10010 is