12,815,057 members (41,518 online)
Rate this:
See more:
Please i needed to a working pseudo code for converting any binary code to its equivalent decimal representation
Posted 23-Jan-13 4:21am

Rate this:

## Solution 1

It's not complex: all you need to do is use the modulus and divide operators until there is no number left:

1) Set `inp` to binary number.
2) Set `digit` to `inp` modulus 10. Output `digit`
3) Set `inp` to `inp` divided by 10
4) If `inp` is not zero, repeat from (2)

The only complication is that this generates the digits in the wrong order: least significant first. So you will need to make your "Output Digit" cope with that, and probably store them in reverse order for output at the end. Exactly how you do that isn't complex, but I don't know how far you have got in your course, so I won't suggest anything - you have probably got an idea from the lecture that this was the homework from.

Top Experts
Last 24hrsThis month
 Jochen Arndt 260 Karthik Bangalore 244 OriginalGriff 120 CHill60 115 F-ES Sitecore 100
 OriginalGriff 4,402 Graeme_Grant 3,649 Karthik Bangalore 3,321 Jochen Arndt 2,306 ppolymorphe 2,287