Special binary codes have been designed to represent decimal numbers. These codes are used extensively in digital logic applications (e.g. arithmetic circuits, encoders, decoders and code converters), and in computer communication applications to provide error detection and correction.
The 8421 Binary Decimal Code: In this code structure, each of the decimal digits (0-9) is represented by a four-bit binary code as illustrated in Table 2-8. Recall that with 4 bits the number of unique representations is 24=16. Thus there are 6 invalid four-bit combinations for the BDC code.
Decimal
BCD
0
0000
1
0001
2
0010
3
0011
4
0100
5
0101
6
0110
7
0111
8
1000
9
1001
Invalid Combinations 1010 1011
1100 1101 1110 1111 Table 2-8 BCD code
Examples: Convert each of the decimal numbers below to BCD A) 546 10 B) 23.8 10 C) 5139 10
A) 5 = 0101, 4 = 0100, 6=0110 thus 546 = (010101000110)
BCD
B) 23.8 = (00100011.1000) BCD C) 5139 = (0101000100111001) BCD
Converting BCD codes to decimal To convert BCD codes to decimal, break the binary digits into groups of four starting from the binary point and convert each group into its appropriate BCD digit.
Examples: Convert each of the BCD numbers below to their decimal equivalent A) 001110000111
B) 01100111.0100
A) (001110000111) BCD = 0011 1000 0111 = (387) 10 B) (01100111.0100) BCD = 0110 0111. 0100