Binary coded decimal or BCD is another process to convert decimal data into binary equivalent data. As we seen in pervious tutorial of binary number section, there are many binary code each has own specification in digital and electronics circuit, with Binary Coded Decimal being one of the main ones. As we live in decimal world we need to convert these decimal numbers into binary that the digital computer can understand.
We have already seen the binary number that has n binary code represent in the 0 and 1 form. The advantage of binary decimal code is that the each decimal digit can be represented by a group of 4 binary digits. Or bit is much same as hexadecimal. So for the decimal digits (0-9) need four binary bits.
But don’t confuse in binary decimal code to hexadecimal both are not same, Whereas a 4-bit hexadecimal number is valid up to F16 representing binary 11112, (decimal 15), the binary code decimal stop at 9 binary 10012. This means that although 16 numbers can be represent using four bits for one and another four bits for six. The 16 representation in binary code decimal is 001 0110.
The main advantage of BCD is that it allow to easy covert to decimal, however the disadvantage is that BCD 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 BCD number the decimal number are separated in individual from and then each decimal number assign four bits of binary bits. So a 4 bits of binary digits display the individual of one 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)
BCD is a weighted code and it is commonly called the 8421 code as it forms the 4-bit binary representation of the relevant decimal digit.
Binary Coded Decimal Representation of a Decimal Number
The decimal weight of each decimal digit increase by factor of 10. In BCD code the binary weight of each digits increase by factor of 2 as shown in figure. 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.
Truth Table for Binary Coded Decimal
|Decimal Number||BCD 8421 Code|
|10 (1+0)||0001 0000|
|11 (1+1)||0001 0001|
|12 (1+2)||0001 0010|
|20 (2+0)||0010 0000|
|21 (2+1)||0010 0001|
|22 (2+2)||0010 0010|
|etc, continuing upwards in groups of four|
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.
As we already seen above, the conversions of decimal to binary code decimal is almost similar to the conversion of hexadecimal to binary from 0 to 9. The conversion of decimal to BCD, separate the decimal number into its weighted digits and write down the equivalent 4-bit 8421 BCD code representing each decimal digit as shown.
Example no 1: Convert Decimal number to BCD Equivalent.
Using the above table, convert the following decimal (denary) numbers: 8510, 57210 and 857910 into their 8421 BCD equivalents.
8510 = 1000 0101 (BCD)
57210 = 0101 0111 0010 (BCD)
857910 = 1000 0101 0111 1001 (BCD)
Note that the resulting binary number after the conversion will be a true binary translation of decimal digits. This is because the binary code translates as a true binary count.
BCD to Decimal conversion
The conversion of BCD to decimal is exactly opposite of the conversion of decimal to BCD. We can simply convert the BCD to decimal; firstly we create the group of four binary bits, starting with the least significant digit and then write the decimal digit represented by each 4-bit group. We add extra zero at the end if we need to make four bits of group. 1101012 would become: 0011 01012 or 3510 in decimal.
Example no 2: Convert BCD to Decimal number equivalent.
Convert the following binary numbers: 10012, 10102, 10001112 and 10100111000.1012 into their decimal equivalents.
10012 = 1001BCD = 910
10102 = this will produce an error as it is decimal 1010 and not a valid BCD number
10001112 = 0100 0111BCD = 4710
10100111000.1012 = 0101 0011 0001.1010BCD = 538.62510
The conversion of decimal to BCD or BCD to decimal is a relatively straight forward task but we need to remember the BCD and decimal is not a binary number. Even through them are representing in bits. The use of BCD is in microcomputer.
It is easy to code and decode. It is not too efficient to store numbers. In BCD the number for representation of decimal no need more binary bits which creates long length due to this it is not efficient to store.
Applications and advantage of binary code decimal
- It is using integer arithmetic.
- It is enables easy conversion between machine-readable and human-readable numerals.
- Comparing with binary number system it is easy to decode and encode.
- It offers a fast and efficient system to convert decimal numbers into binary numbers.
- It is use in seven segment display, where it can be difficult to manipulate or display large numbers.
- It is also used in some currency applications where floating point representations are not completely accurate.
Disadvantage of BCD number
It has certain limitation which are given below-
- It is not efficient to store in computer memory.
- BCD increasers circuits complexity.
- It is wasteful above 10 to 16.
Types of binary-coded decimal
There are two types of binary-coded decimal.
Unpacked binary-coded decimal
In unpacked binary-coded decimal numbers, each 4-bit binary-coded decimal group is stored in a separate register inside a computer. The drawback here is that, if the registers are 8 bits or wider, space is wasted storing the binary-coded decimal numbers.
Packed binary-coded decimal
In packed binary-coded decimal numbers, a single 8-bit register stores two binary-coded decimal digits. By shifting the number in the upper register to the left four times and then adding the numbers in the upper and lower registers, the process combines two binary-coded decimal digits, which enables storage in a single register.