# BCD Code

In order to share information in digital format, it is common to use a binary or hexadecimal representations (**BCD Code**). There are other methods to represent this information and one of them is the **BCD code**. By using the BCD coding is easy to see the relationship between a decimal number (base 10) and the corresponding binary one (base 2)

This code uses 4 binary digits to represent a decimal number (0 to 9). When you make a normal convertion from a binary number to a decimal one there is no direct relationship between the decimal digit and the binary digit.

Example #1:

This is a direct normal convertion from a decimal number to a binary one. 85_{10} = 1010101_{2. }The representation of the same decimal number on **BCD code** is shown above.

Example # 2:

This is a direct normal convertion from a decimal number to a binary one. 568_{10} = 1000111000_{2}. Representation of the same decimal number on **BCD code** is shown above.R

As you can see from the two examples, the decimal equivalent number does not seem to be a good **BCD** representation. To obtain the equivalent **BCD code** of each previous decimal number, we have to assign a “weight” or “value” to each digit according to its position.

This “weight” or “value” follows the following order: 8 – 4 – 2 – 1. (It is a weighted code)

The last example shows that the number 5 is represented as: 0 1 0 1.

the first “0” corresponds to 8,

the first “1” corresponds to 4,

the second “0” corresponds to 2, and …

the second “1” corresponds to 1.

From the chart above: 0x8 + 1×4 + 0x2 + 1×1 = 5

The **BCD code** that has the “weights” or “values” described before is called: **Natural BCD Code**. The **BCD code** counts like a normal binary number from 0 to 9, but numbers from ten (1010) to fifteen (1111) are not used because these numbers do not have an equivalent decimal number. This code is used, among other applications, to represent decimal numbers on 7 segment displays.

**Notes:** The subscript 2 and 10, are used to represent, in the first case a binary number and in the second case a decimal number.