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 F_{16} representing binary 1111_{2}, (decimal 15), the binary code decimal stop at 9 binary 1001_{2}. 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, 357_{10} (Three Hundred and Fifty Seven) in decimal would be presented in Binary Coded Decimal as:

357_{10} = 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**

Binary Power | 2^{3} |
2^{2} |
2^{1} |
2^{0} |

Binary Weight: | 8 | 4 | 2 | 1 |

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 ( 2^{0} ), the second digit has a weight of 2 ( 2^{1} ), the third a weight of 4 ( 2^{2} ), the fourth a weight of 8 ( 2^{3} ).

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 |

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 |

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.

**Decimal-to-BCD Conversion**

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: 85_{10}, 572_{10} and 8579_{10} into their 8421 BCD equivalents.

85_{10} = 1000 0101 (BCD)

572_{10} = 0101 0111 0010 (BCD)

8579_{10} = 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. 110101_{2} would become: 0011 0101_{2} or 35_{10} in decimal.

**Example no 2: Convert BCD to Decimal number equivalent. **

Convert the following binary numbers: 1001_{2}, 1010_{2}, 1000111_{2} and 10100111000.101_{2} into their decimal equivalents.

1001_{2} = 1001_{BCD} = 9_{10}

1010_{2} = this will produce an error as it is decimal 10_{10} and not a valid BCD number

1000111_{2} = 0100 0111_{BCD} = 47_{10}

10100111000.101_{2} = 0101 0011 0001.1010_{BCD} = 538.625_{10}

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.