Qbasic Help

wildwarren

Senior member
Mar 22, 2001
300
2
0
I'm sure its been a while for most anyone that knows Qbasic, hehe, but this is straight from my dinky comp programming class in High School.

My assignment is to write a program for converting decimal numbers to binary and then another for decimal to hex.

If you don't remember the code for it, maybe help me out with the equation. Thanks
 

RedFox1

Senior member
Aug 22, 2000
587
0
76
To convert a number to binary all you need to do is keep dividing by 2, and recording the remainder. The final remainder then becomes the first bit in the binary number, and so forth.

Say you have the number "35"
35/2 = 17, remainder 1
17/2 = 8, remainder 1
8/2 = 4, remainder 0
4/2 = 2, remainder 0
2/2 = 1, remainder 0
1/2 = 0, remainder 1

So, "35" translates to "100011"

Converting to Hex works the same way, except you divide by 16. For a remainder of "1" record a "1", for a remainder of 15 record a "F".

-Russ