20
Digital Electronics
Table 2.1 BCD codes.
Decimal 8421 BCD code 4221 BCD code 5421 BCD code
0
0000
0000
0000
1
0001
0001
0001
2
0010
0010
0010
3
0011
0011
0011
4
0100
1000
0100
5
0101
0111
1000
6
0110
1100
1001
7
0111
1101
1010
8
1000
1110
1011
9
1001
1111
1100
weight. Other weighted BCD codes include the 4221 BCD and 5421 BCD codes. Again, 4, 2, 2 and
1 in the 4221 BCD code and 5, 4, 2 and 1 in the 5421 BCD code represent weights of the relevant
bits. Table 2.1 shows a comparison of 8421, 4221 and 5421 BCD codes. As an example, (98.16) 10
will be written as 1111 1110.0001 1100 in 4221 BCD code and 1100 1011.0001 1001 in 5421 BCD
code. Since the 8421 code is the most popular of all the BCD codes, it is simply referred to as the
BCD code.
2.1.1 BCD-to-Binary Conversion
A given BCD number can be converted into an equivalent binary number by first writing its decimal
equivalent and then converting it into its binary equivalent. The first step is straightforward, and the
second step was explained in the previous chapter. As an example, we will find the binary equivalent
of the BCD number 0010 1001.0111 0101:
• BCD number: 0010 1001.0111 0101.
• Corresponding decimal number: 29.75.
• The binary equivalent of 29.75 can be determined to be 11101 for the integer part and .11 for the
fractional part.
• Therefore, (0010 1001.0111 0101) BCD = (11101.11) 2 .
2.1.2 Binary-to-BCD Conversion
The process of binary-to-BCD conversion is the same as the process of BCD-to-binary conversion
executed in reverse order. A given binary number can be converted into an equivalent BCD number
by first determining its decimal equivalent and then writing the corresponding BCD equivalent. As an
example, we will find the BCD equivalent of the binary number 10101011.101:
• The decimal equivalent of this binary number can be determined to be 171.625.
• The BCD equivalent can then be written as 0001 0111 0001.0110 0010 0101.
Digital Electronics
Table 2.1 BCD codes.
Decimal 8421 BCD code 4221 BCD code 5421 BCD code
0
0000
0000
0000
1
0001
0001
0001
2
0010
0010
0010
3
0011
0011
0011
4
0100
1000
0100
5
0101
0111
1000
6
0110
1100
1001
7
0111
1101
1010
8
1000
1110
1011
9
1001
1111
1100
weight. Other weighted BCD codes include the 4221 BCD and 5421 BCD codes. Again, 4, 2, 2 and
1 in the 4221 BCD code and 5, 4, 2 and 1 in the 5421 BCD code represent weights of the relevant
bits. Table 2.1 shows a comparison of 8421, 4221 and 5421 BCD codes. As an example, (98.16) 10
will be written as 1111 1110.0001 1100 in 4221 BCD code and 1100 1011.0001 1001 in 5421 BCD
code. Since the 8421 code is the most popular of all the BCD codes, it is simply referred to as the
BCD code.
2.1.1 BCD-to-Binary Conversion
A given BCD number can be converted into an equivalent binary number by first writing its decimal
equivalent and then converting it into its binary equivalent. The first step is straightforward, and the
second step was explained in the previous chapter. As an example, we will find the binary equivalent
of the BCD number 0010 1001.0111 0101:
• BCD number: 0010 1001.0111 0101.
• Corresponding decimal number: 29.75.
• The binary equivalent of 29.75 can be determined to be 11101 for the integer part and .11 for the
fractional part.
• Therefore, (0010 1001.0111 0101) BCD = (11101.11) 2 .
2.1.2 Binary-to-BCD Conversion
The process of binary-to-BCD conversion is the same as the process of BCD-to-binary conversion
executed in reverse order. A given binary number can be converted into an equivalent BCD number
by first determining its decimal equivalent and then writing the corresponding BCD equivalent. As an
example, we will find the BCD equivalent of the binary number 10101011.101:
• The decimal equivalent of this binary number can be determined to be 171.625.
• The BCD equivalent can then be written as 0001 0111 0001.0110 0010 0101.
