Binary Coded Decimal
Binary Coded Decimal
many different binary codes used in digital and electronic circuits, each
with its own specific use.
As we naturally live in a decimal (base-10) world we need some way of
converting these decimal numbers into a binary (base-2) environment
that computers and digital electronic devices understand, and binary
coded decimal code allows us to do that.
We have seen previously that an n-bit binary code is a group of “n” bits
that assume up to 2n distinct combinations of 1’s and 0’s. The advantage
of the Binary Coded Decimal system is that each decimal digit is
represented by a group of 4 binary digits or bits in much the same way
as Hexadecimal. So for the 10 decimal digits (0-to-9) we need a 4-bit
binary code.
But do not get confused, binary coded decimal is not the same as
hexadecimal. Whereas a 4-bit hexadecimal number is valid up
to F16 representing binary 11112, (decimal 15), binary coded decimal
numbers stop at 9 binary 10012. This means that although 16 numbers
(24) can be represented using four binary digits, in the BCD numbering
system the six binary code combinations of: 1010 (decimal
10), 1011 (decimal 11), 1100 (decimal 12), 1101 (decimal
13), 1110 (decimal 14), and 1111 (decimal 15) are classed as forbidden
numbers and can not be used.
The main advantage of binary coded decimal is that it allows easy
conversion between decimal (base-10) and binary (base-2) form.
However, the disadvantage is that BCD code is wasteful as the states
between 1010 (decimal 10), and 1111 (decimal 15) are not used.
Nevertheless, binary coded decimal has many important applications
especially using digital displays.
In the BCD numbering system, a decimal number is separated into four
bits for each decimal digit within the number. Each decimal digit is
represented by its weighted binary value performing a direct translation
of the number. So a 4-bit group represents each displayed decimal digit
from 0000 for a zero to 1001 for a nine.
So for example, 35710 (Three Hundred and Fifty Seven) in decimal
would be presented in Binary Coded Decimal as:
35710 = 0011 0101 0111 (BCD)
Then we can see that BCD uses weighted codification, because the
binary bit of each 4-bit group represents a given weight of the final
value. In other words, the BCD is a weighted code and the weights used
in binary coded decimal code are 8, 4, 2, 1, commonly called the 8421
code as it forms the 4-bit binary representation of the relevant decimal
digit.
Binary Power 23 22 21 20
Binary Weight: 8 4 2 1
The decimal weight of each decimal digit to the left increases by a factor
of 10. In the BCD number system, the binary weight of each digit
increases by a factor of 2 as shown. Then the first digit has a weight
of 1 ( 20 ), the second digit has a weight of 2 ( 21 ), the third a weight
of 4 ( 22 ), the fourth a weight of 8 ( 23 ).
Then the relationship between decimal (denary) numbers and weighted
binary coded decimal digits is given below.
0 0000 0000
1 0000 0001
2 0000 0010
3 0000 0011
4 0000 0100
5 0000 0101
6 0000 0110
7 0000 0111
8 0000 1000
9 0000 1001
Then we can see that 8421 BCD code is nothing more than the weights
of each binary digit, with each decimal (denary) number expressed as
its four-bit pure binary equivalent.
Decimal-to-BCD Conversion
As we have seen above, the conversion of decimal to binary coded
decimal is very similar to the conversion of hexadecimal to binary.
Firstly, separate the decimal number into its weighted digits and then
write down the equivalent 4-bit 8421 BCD code representing each
decimal digit as shown.
BCD-to-Decimal Conversion
The conversion from binary coded decimal to decimal is the exact
opposite of the above. Simply divide the binary number into groups of
four digits, starting with the least significant digit and then write the
decimal digit represented by each 4-bit group. Add additional zero’s at
the end if required to produce a complete 4-bit grouping. So for
example, 1101012 would become: 0011 01012 or 3510 in decimal.