BCD Code
BCD code or Binary coded Decimal codes. It is a numeric weighted binary codes, where every digit of a decimal number is expressed by a separate group of 4-bits. There are various BCD codes like 8421, 2421, 5211, etc. The BCD code is also known as the 8421 code.
Decimal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
BCD | 0000 | 0001 | 0010 | 0011 | 0100 | 0101 | 0110 | 0111 | 1000 | 1001 |
These codes are very useful and convenient for input and output operations in digital circuits. In the 8421 code, the weights linked with 4 bits are 8, 4, 2, 1 from MSB to LSB. That is, the weight of the 3rd bit is 8, the weight for the 2nd bit is 4, the weight linked with the 1st bit is 2 and the weight associated with the 0th bit is 1. Below is an example to understand the 8421 code.
94→ 9 4
↓ ↓
Code→ 8+4+2+1 8+4+2+1
1+0+0+1 0+1+0+0
\(In\ a\ 4-bit\ binary\ format,\ the\ total\ number\ of\ possible\ representation\ is \)
\(=2^4=16\)
\(Where\ Valid\ BCD\ codes=10\)
\(and\ Invalid\ BCD\ codes=6\)
\(Similarly\ in\ a\ 8-bit\ binary\ format,\ the\ total\ number\ of\ possible\ representation\ is\)
\(=2^8=256\)
\(Where\ Valid\ BCD\ codes=100\)
\(and\ Invalid\ BCD\ codes=256-100=156\)
Learn about the AND Gate here.
Similarly, in the 2421 Code for a 4-bit code, the binary weights carry 2, 4, 2, 1 from left to right. Whereas for 5211 Binary Code for a 4-bit code the binary weights carry 5, 2, 1, 1 from left to right.
94→ 9 4
↓ ↓
Code→ 2+4+2+1 2+4+2+1
1+1+1+1 0+1+0+0
94→ 9 4
↓ ↓
Code→ 5+2+1+1 5+2+1+1
1+1+1+1 0+1+1+1
Advantages of BCD Codes
- It is very similar to a decimal system and relatively easy to convert to and from decimal.
- It is required to remember the binary equivalent of decimal numbers from 0 to 9 only.
- The conversion of binary to decimal and vice versa is important from the hardware viewpoint.
Disadvantages of BCD Codes
- The addition and subtraction of BCD have separate rules.
- The BCD calculation is a little more complex.
Check the Computer Storage Devices here.