Binary Coded Decimal:
Binary coded decimal(BCD) is a way to express each of the decimal digits with a binary code.
There are only ten code group in the BCD system, so it is very easy to convert between decimal and BCD.
The 8421 BCD Code:
The 8421 BCD code is a binary-coded decimal (BCD) code that represents a decimal number as a four-bit binary number, where each bit represents one of the decimal digits 8, 4, 2, and 1.
Invalid Codes:
Invalid BCD codes are binary-coded decimal (BCD) codes that do not represent a valid decimal digit. The 8421 BCD code has six invalid codes, which are:
- 1010
- 1011
- 1100
- 1101
- 1110
- 1111
Note: These codes are invalid because they do not correspond to any of the decimal digits 0 to 9.
The Gray Code:
The Gray code is a binary code in which two successive values differ in only one bit. This means that any two adjacent Gray codes differ by only one bit in their binary representation.
The Gray code is named after Frank Gray, who invented it in 1953. It is also known as the reflected binary code, because the first half of the Gray code is simply a reflection of the second half.
Binary to Gray code conversion:
Rules:
- The most significant bit (MSB) of the Gray code is the same as the MSB of the binary code.
Gray to Binary code conversion:
Rules:
- The most significant bit (MSB) of the binary code is the same as the MSB of the Gray code.