Appendix A.2: Binary Coded Decimal (BCD)#
Binary Coded Decimal, also known as BCD or 8421 format is another widely used numbering system whereby each decimal digit from 0-9 is individually represented as a 4-bit binary number between ``0000and
1001`.
The main advantage of binary coded decimal is that it allows easy conversion between decimal and binary form.
Where is BCD used
Calculators
Decimal display drivers
Digital Clock
PC BIOS to store date and time
Binary Coded Decimal shows the codes for the 10 values that are used in BCD coded representations.
Decimal |
BCD Coding |
---|---|
0 |
|
1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
Examples#
\(5_{10} ≡ 0101_\textrm{BCD}\)
\(22_{10} ≡ 0010\, 0010_\textrm{BCD}\)
\(86_{10} ≡ 1000\, 0110_\textrm{BCD}\)
\(2020_{10} ≡ 0010\, 0000\, 0010\, 0000_\textrm{BCD}\)
Pros and Cons of Binary Coded Decimal#
Pros#
Simple to convert between BCD and decimal values.
SLess data loss in floating point calculations.
Cons#
Requires more complex circuitry.
Wasteful as only uses 10 out of 16 possible 8-bit representations.
Requires more storage than other encoding systems.
\(15_{10} = 1111_2 = 0001\, 0101_\textrm{BCD}\)
\(255_{10} = 1111\, 1111_2 = 0010\, 0101\, 0101_\textrm{BCD}\)
\(8579_{10} = 0010\, 0001\, 1000\, 0011_2 = 1000\, 0101\, 0111\, 1001_\textrm{BCD}\)