Discussion Locked

decimal # to binary #

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

decimal # to binary #
If anyone out there has a solution to this problem please contact me...

1 Create an applet code in JBuilder 4 to convert binary numbers to decimal numbers.

2 I need another program that takes a decimal and converts it into a binary number.

Contact me at
GravesendINC@AOL.COM

1 reply

by quantum jim

So I'll just post some hints.

1. To Convert the base-2 number ABCDEFG to base-10, use the result of the formula:

G*2^0 +F*2^1 +E*2^3 +D*2^4 +C*2^5 +B*2^6 +A*2^7

See a pattern? Here's a hint: If the number was ZABCDEFG then the exponet for the two of the Z'th digit would be 8.

2. To convert from base-10 to base-2, use modulo arthimitic. For instance, to convert 243 to base-2:

N N\2 Remainder
243 121 1
121 060 1
060 030 0
030 015 0
015 007 1
007 003 1
003 001 1
001 000 1
Then the base-2 number is 11110011. Hint: you can use recursion to implement that function.

Hope that helps!

This discussion is closed to new replies.