Earlier, we learned that BCD code and the binary equivalent of a decimal number are different. In this article, we will learn that how to convert binary to BCD and vice versa.
To convert binary to BCD, we will first convert the binary number to decimal and then the decimal number to BCD number. Similarly, to convert BCD to binary, we will first convert the BCD to decimal and then decimal to equivalent binary.
Example 1: Convert the binary number 11010110 to BCD.
Solution:
First of all, we would convert the binary number 11010110 to decimal.
110101102 = 21410 (check here for binary to decimal conversion)
Now, we will convert the decimal number 214 to a BCD number.
110101102 = 001000010100BCD
From the above example, you can realize that the binary equivalent and BCD of a decimal number are not the same, though both of them are represented using 0s and 1s.
Example 2: Convert the BCD number 100101101000 to binary number.
Solution:
First of all, we would convert the BCD number 100101101000 to decimal.
Now, we will convert the decimal number 968 to a binary number. Check here to learn the steps for converting a decimal number to a binary number.
96810 = 11110010002
So, we can write 100101101000BCD = 11110010002