I would like to know what is a general rule of thumb to convert between the following number systems:
Decimal
Octal
Hexadecimal
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.
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.