The correct method for converting numbers from one base to another depends on your starting base and your target base. It is critical to use the right method for the conversion, since you will get completely wrong results otherwise. The various types of conversions that we use, and the appropriate methods, are summarized below, with examples.
Converting ANY Other Number Base to Decimal (base 10)
Converting TO a decimal number requires using the positional notation system to calculate the decimal value of each digit in the original base:
- Start with the original number.
- Multiply each digit by the original base raised to the correct power, starting from the rightmost digit:
- Rightmost digit times base to the zero power, which is ALWAYS one
- Second digit times base to the first power, which is ALWAYS the base itself
- Third digit times base to the second power (the base squared)
- Fourth digit times base to the third power (the base cubed)
- and so on for each digit in the original number
- When all the digits have been converted to their decimal value, add up the decimal values.
- The result is the converted value in decimal.
|Example: Convert 754 in base 8 to base 10:
4 * 8 to the 0 power = 4 * 1 = 4
448 + 40 + 4 = 492 in base 10
|Example: Convert F3A in base 16 to base 10:
A * 16 to the 0 power = 10 * 1 = 10
3840 + 48 + 10 = 3898 in base 10
|Example: Convert 11101 in base 2 to base 10:
1 * 2 to the 0 power = 1 * 1 = 1
16 + 8 + 4 + 1 = 29 in base 10
Converting Decimal to ANY Other Number Base
Converting FROM a decimal number to any other number base involves determining how many times each power of the new base goes into the decimal number. This means you have to remember how to do “long division” with quotients and remainders, as opposed to division with decimals or fractions
- Divide your decimal value by the base you are converting to. Stop dividing when you get a remainder that is less than your base (in other words, don’t go past the decimal point).
- Take the remainder (remember, it’s less than the base!) and make it the RIGHTMOST digit in your converted number.
Note: if you are converting to a base greater than 10, AND that remainder is 10 or greater, you MUST convert that two-digit remainder to a single digit in your target base.
- Now look at your quotient. Is it zero? If so, you are DONE (HOORAY!!).
- If not, take that quotient, and divide it by the base you are converting to. Stop dividing when you get a remainder that is less than your base (in other words, don’t go past the decimal point). Yes, this is basically repeating step 1.
- Take the remainder from step 4, and make it the NEXT digit to the LEFT (repeat, LEFT!!!) in your converted number. You MUST build the number from RIGHT to LEFT.
- Go back to step 3.
|Example: Convert 1192 from base 10 to base 2
1192 / 2 = 596, remainder 1 -> 0
|Example: Convert 1192 from base 10 to base 8
1192 / 8 = 149, remainder 0 -> 0
|Example: Convert 1192 from base 10 to base 16
1192 / 16 = 74, remainder 8 -> 8
Converting Between Binary and Octal
|Binary to Octal:
Example: Convert 11010001 from binary to octal.
11 010 001
011 -> 3, 010 -> 2, 001 -> 1
11010001 = 321
Octal to Binary:
Example: Convert 7361 from octal to binary.
7 -> 111, 3 -> 001, 6 -> 110, 1 -> 011, so 7361 in octal = 00001110 01110011 in binary.
Converting Between Binary and Hexadecimal
|Binary to Hexadecimal:
Example: Convert 11010001 from binary to hexadecimal.
1101 -> D
11010001 = D1
Hexadecimal to Binary:
Example: Convert C7A from hexadecimal to binary.
C -> 1100, 7 -> 0111, A -> 1010, so C7A = 00001100 01111010 in binary.
Converting Between Octal and Hexadecimal
This conversion can be done directly if you REALLY want to, but I don’t recommend it at all. It’s far, far easier to convert from the starting base to binary, as described above, then from binary to the target base. Doing it this way means you don’t have to do any actual calculation at all!
|Convert 741 in base 8 to base 16
7 4 1 -> 111 100 011 -> 111100011 -> 1 1110 0011 -> 1 E 3
741 in base 8 is 1E3 in base 16
|Convert EB7 in base 16 to base 8
E B 7 -> 1110 1011 0111 -> 111010110111 -> 111 010 110 111 -> 7 2 6 3
EB7 in base 16 is 7263 in base 8