• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Qbasic Help

wildwarren

Senior member
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
 
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
 
Back
Top