In the previous lesson, we learned about binary codes and how they are used for representing a distinct discrete element of information using 1s and 0s.

#### Binary Coded Decimal Overview

People use decimal system for everything and it’s easier for them to use decimal numbers on computer than binary numbers. But binary is what computer understands.

So we need a system to convert decimal to binary and perform calculation using binary numbers and convert the output back to decimal for users.

This binary representation of decimal number is called the *binary coded decimal code or BCD code.*

#### Binary-Coded Decimal (BCD code)

The binary coded decimal is a 4-bit code and each 4-bit code is represents one decimal digit from 0 to 9. See the table below,

Decimal Digit | Binary Coded Decimal |

0 | 0000 |

1 | 0001 |

2 | 0010 |

3 | 0011 |

4 | 0100 |

5 | 0101 |

6 | 0110 |

7 | 0111 |

8 | 1000 |

9 | 1001 |

But there are 16 codes because 2^{4} = 16 combinations. The codes from 1010 to 1111 does not matter and are not used in BCD.

For example

The binary and BCD value of 128 is given below for your understanding.

Binary number for 128_{10} | BCD Code for 128_{10} |

1000 0000 | 0001 0010 1000 |

#### Important points to remember

- Decimal number is 0, 1, 2, 3, so on, and BCD code is 0000, 0001, 0011… It means they are same.
- Binary number is not BCD, there is a difference.
- BCD coded decimal numbers need more bits. See the example above.

#### BCD Addition

When two BCD numbers are added then two things happens

- Sum is less than 1010 = decimal 10
- Sum is equal to or more than decimal 10

Suppose you add following BCD numbers

4 + 3 |

0100 |

0011 |

0111 = 7 |

The result is a BCD sum and less than 1010.

**First Case – when BCD sum does not have a carry**

Consider another example,

8 + 4 |

1000 |

0100 |

1100 = 12 |

The BCD does not allow 1100 and we need 12 as answer in BCD. The first digit is 1 and second digit is 2.

There are 16 codes in BCD and we are using only 10 of them.

1010 + 0110 = 1 carry + 0000 = 0001 0000 = 10 in BCD

1011 + 0110 = 1 carry + 0001 = 0001 0001 = 11 in BCD

1100 + 0110 = 1 carry + 0010 = 0001 0010 = 12 in BCD

1101 + 0110 = 1 carry + 0011 = 0001 0011 = 13 in BCD

1110 + 0110 = 1 carry + 0100 = 0001 0100 = 14 in BCD

1111 + 0110 = 1 carry + 1000 = 0001 0101 = 15 in BCD

Then whenever, you get an invalid BCD sum, add a 0110 = 6 to the result and you will get the correct BCD sum.

**Second Case – when BCD sum has a carry**

We not look at another case of BCD sum when the result appears to be correct but it has a carry.

8 + 9 = 1000

+ 1001

============

1 0001

In this case, we still add 0110 = 6 to the 4 least significant bits.

1 0001

0110

============

1 0111 = 1 carry + 0111 = > 0001 0111 = 17_{10}

**Example – BCD Addition**

In this example, we will add two decimal numbers,

214 + 389 = 603

0010 + 1 0001 + 1 0100 = **214**

+0011 1000 1001= **389**

======================================

0110 1010 1101

0110 0110

=====================================

0110 0000 0011 = **603**

### Bibliography

John.F.Wakerly. 2008. *Digital Design: Principles And Practices, 4/E.* Pearson Education, India.

Mano, M. Morris. 1984. *Digital Design.* Pearson.