Electronics Engineering Question:

How to convert a binary number into BCD number directly and vice-versa, without converting it into any other number system?

Tweet Share WhatsApp

Answer:

It depends on the range. An algorithm can be used.

For a number in the range of 0 to 19 (decimal), the following algorithm can be used:

if a<10
a_BCD=a;
else if a<20
a_BCD=a+0x06;
end

for example if a=0x0E, then a_BCD=0x0E+0x06=0x14, which is the BCD representation of 0x0E.

This could be generalized for a number in the range of 0 to 99: a_BCD=a+n*0x06, where 10*n<=a<10*(n+1).

Download Electronics Engineering PDF Read All 185 Electronics Engineering Questions
Previous QuestionNext Question
Explain differences between microprocessor and micro controller?What is hybrid parameter?