# General rule of thumb to convert between number systems.

I would like to know what is a general rule of thumb to convert between the following number systems:
Decimal
Octal
Binary

I know if I want to convert from octal to hexadecimal, I first convert the octal number to binary with groups of 3 bits and then I regroup the binary number to groups of 4 bits, starting from the right to left. Finally, I convert the binary number to hexadecimal by adding up the bit values.
I know if I want to convert from decimal to binary, I can just divide the decimal number by 2 and keep track of the remainder until the quotient is 0. The answer will be the remainders from the most significant bit to the least significant bit.

Because there are so many number systems to convert between, decimal to binary to octal to hexadecimal etc, I sometimes forget which method to use for which conversion.
I figured that if I need to convert from decimal that I just need to divide by the base of the number system which I'm converting to. For example, from decimal to binary, divide by 2 and keep track of the remainders for each calculations and from decimal to octal divide by 8, etc. This makes it easy to understand if I convert from decimal. I need some rule like this for all conversions.

How can I always know which method to use. Is there a general rule of thumb?
Thank you.

• With computing, why would you ever spend time learning old-fashioned "hand" rules of thumb, which you'll rarely if ever use, which you'll forget, and which will not help you on realistic (many digit) cases? Given you're asking this question on this site, you can always just type it into WolframAlpha and devote your energies to more valuable problems. – David G. Stork May 25 '20 at 22:11
• @DavidG.Stork: the OP is wrong to use the term "rules of thumb", the methods for pen-and-paper calculation are algorithms. You are quite wrong to dismiss these algorithms as irrelevant because (a) the people who implement them on computers have to know how to do so and (b) the algorithms throw some insight into how numbers work. – Rob Arthan May 25 '20 at 22:18
• @RobArthan: a) If the OP wanted to implement radix conversion on a computer he should have asked about that instead. The rules of thumb for hand calculation are almost always profoundly different from those implemented on a computer. b) The OP mentions nothing about "how numbers work," and (apparently) just wants to convert radixes during his work. So: you and I should watch the "solutions" come in and see if they relate to your a) and b). See also: ted.com/talks/… – David G. Stork May 25 '20 at 22:25
• @DavidG.Stork: well, we have one answer in now. And aside from the special casing for bases that are powers of $2$, Ross Millikan is telling us about the algorithms that are used both on paper and in silicon. – Rob Arthan May 25 '20 at 22:31
• @RobArthan: The OP stated explicitly: "I know if I want to convert from decimal to binary, I can just divide the decimal number by 2 and keep track of the remainder until the quotient is 0." So... um... the solution contributed exactly what (even if you upvoted it)? – David G. Stork May 25 '20 at 22:35

The conversions between binary, octal, and hex can be done by groups of digits like you have done because those bases are all powers of $$2$$. The hardest is between octal and hex because four octal digits correspond to three hex digits, but you can either keep track of that or go through binary.
Generally, any other base conversion must be done in one of the two ways between decimal and binary. You can either divide by $$2$$ repeatedly and keep track of the remainders, or you can subtract the largest power of $$2$$ that fits into the number and keep track of those. This will also work between the bases that are powers of two, but the special method keeping groups of bits together is easier.