# Practical Electronics/Binary-coded Decimal

Binary-coded Decimal or BCD is a way of representing a decimal number as a string of bits suitable for use in electronic systems. Rather than converting the whole number into binary, BCD splits the number up into its digits and converts each digit to 4-bit binary.

Thus, for example, 345 becomes

```0011 0100 0101
```

This is 3 digits longer than the real binary equivalent of 345, 101011001, but it has several advantages:

• It can easily be used to drive displays, as each digit is encoded separately.
• It allows easy conversion to decimal; true binary to decimal conversion is difficult and gets increasingly difficult as the number gets longer.
• It allows easy scaling by factors of 10

It also has disadvatages:

• It is difficult to perform arithmetic operations (such as adding) on BCD numbers, as it is not as easy to recognise carries, etc.
• It is longer than true binary, and so require more storage space.

Converting binary number (example: 255 is 11111111 binary) to binary-coded decimal (reads as 10, 101,101) can be done by dividing by 10 (decimal). The remainder is the digit starting at the ones place, and the quotient is to be divided by 10 again and the quotient would be the next digit. This step repeats until the quotient is 0. In this example:

```255/10 = 25 R: 5 [xx5]
25/10 = 2  R: 5 [x55]
2/10 = 0  R: 2 
```

To convert from binary-coded decimal to binary, have each "digit" multiplied by 10x where X is the place value (0 for ones, 1 for tens, 2 for hundreds...) and add all of them all up (2*102)+(5*101)+(5*100) = 255.

## ICs

Several ICs are available to handle BCD counting:

• 4028 - BCD-to-decimal decoder
• 4029 - BCD/true-binary counter
• 4510 - BCD decade counter
• 4511 - BCD 7-segment display driver