# Converting a decimal number to binary

Discussion in 'The Projects Forum' started by toothpick5, Sep 28, 2009.

1. ### toothpick5 Thread Starter New Member

Sep 28, 2009
4
0
I'm trying to build a circuit that will convert decimal numbers into binary with a keypad.
It is no problem as long as the number is a single-digit, but it gets confusing when the user clicked 2 buttons or more.

for example when the user clicked digit number 1 and then 2, the circuit has to multiply the first digit by 10, and then add the 2.

I have circuits that can add binary numbers and multiply them (and I prefer not having any IC's in this part of circuit).

anyone has a suggestion or can reference me to a useful article i can read about it?

Thanks.

2. ### blueroomelectronics AAC Fanatic!

Jul 22, 2007
1,758
98
A microcontroller sounds like the way to go.

3. ### toothpick5 Thread Starter New Member

Sep 28, 2009
4
0
i know, but im trying to avoid the 'easier' option

4. ### blueroomelectronics AAC Fanatic!

Jul 22, 2007
1,758
98
And without ICs that's an odd request.

Apr 20, 2004
15,815
282
6. ### SgtWookie Expert

Jul 17, 2007
22,182
1,728
You really don't want to convert back and fourth from BCD (binary coded decimal) to binary without using a microcontroller.

If you don't believe me, find the datasheet that Texas Instruments published for the SN74184 and SN74185. These are IC's dedicated to converting BCD to binary ('184) and binary to BCD ('185).

To convert a 2-digit number from BCD to binary requires two '184 IC's.
To convert a 3-digit number from BCD to binary requires six '184 IC's.
To convert a 6-digit number from BCD to binary requires twenty eight '184 IC's.

If you want to go the other way, with a 16 bit binary number to BCD only requires sixteen '185 IC's to get a 5-digit BCD output.

Now if you want to try building the code converters out of individual logic gates, be my guest. You will need a circuit board about the size of your living room, a gigantic pile of logic ICs, and a 20lb spool of solder to connect everything up. Oh, don't forget the vacuum cleaner to pick up the hair from the floor that you'll be pulling out of your head.

If you wanted to get "sneaky", you could use a couple of EEproms with the conversions burned into it. Most people don't have EEprom programmers anymore though. Just as easy to burn the tables into a uC; but you don't have to do that either.

7. ### BillB3857 Senior Member

Feb 28, 2009
2,399
348
You could look up the ICs you have that do the multiply and add functions and get the data sheets for them. They sometimes show the internal logic and you could use diodes and transistors to duplicate that logic. Sure seems like a lot of work........

8. ### toothpick5 Thread Starter New Member

Sep 28, 2009
4
0
i came up with the multiply and add functions using some Or, And and Xor gates, it wasnt that much of a problem.

9. ### toothpick5 Thread Starter New Member

Sep 28, 2009
4
0
ok... so how does the BCD to binary or binary to BCD IC's really work?

Apr 20, 2004
15,815
282