Conversion between different Bases 

Conversion to Decimal

In general a number An An-1 _ A2 A1 A0 in a system with base r is basically equal to:

A0 + A1*r1 + A2*r2 + A3*r3 + _ + An*rn in decimal as illustrated by the next examples:

 Examples on converting from different bases to Decimal
Convert the following to Decimal:
  1. (1001001)2
  2. (203)8
  3. (FA07)16


  1. (1001001)2 = 1 + 0*21 + 0*22 + 1*23 + 0*24 + 0*25 + 1*26 = 73d

  2. (203)8 = 3 + 0*81 + 2*82 = 131d

  3. (FA07)16 = 7 + 0*161 + 10*162 + 15*163 = 64007d

Conversion Between Binary, Octal and Hexadecimal

  1. Conversion from Octal and Hexadecimal to binary:

    Each octal digit can be replaced by its 3-bit equivalent binary number and each Hexadecimal digit can be replaced by its 4-bit binary number to form the binary equivalent. This process is illustrated in Figures 2.1 and 2.2 Below.

    Fig. m010222.1 Conversion process from Hexadecimal to Binary

    Fig. m010222.2 Conversion process from Octal to Binary

  2. Conversion from Binary to Octal and Hexadecimal:

    Reverse the process above; start from the least significant bit and replace each 3-bits by their Octal equivalent or each 4-bits by their Hexadecimal equivalent. If there are less than 3-bits (for Octal conversion) or less than 4-bits (for the Hexadecimal conversion), fill the most significant bits with 0s. Figures 2.3 and 2.4 illustrate this process.

    Fig. m010222.3 Conversion process from Binary to Hexadecimal

    Fig. m010222.4 Conversion process from Binary to Octal

  3. Conversion between Octal and Hexadecimal:

    The easiest way to convert between Octal and Hexadecimal is to first convert to Binary and then reconvert to the other system.

 Example on converting from Hexadecimal to Octal
Converting (FA07)16 to Octal:

  1. First convert the hexadecimal number FA07h to binary:


  2. Now convert this back to Octal:


Conversion From Decimal to Binary, Octal or Hexadecimal

To convert from decimal to any numbering system with base r :

The decimal number is divided by r,

Keeping the remainder aside, the result is further divided by r, and the new remainder is kept aside,

The new result is divided again by r, and so on till the result is less than r and this would be the last remainder,

The remainders make up the equivalent base-r number, with the last remainder being the most-significant digit and the first remainder being the least-significant digit.


The examples below best illustrate the conversion process from decimal to binary, octal and hexadecimal.

 Converting 122d to binary, octal and hexadecimal

First conversion to Binary:
Dividend QuotientRemainder
122610 <--- LSB
101 <--- MSB

Hence the result is:


Second, the conversion to Octal:
Dividend QuotientRemainder
122152 <--- LSD
101 <--- MSD

Hence the result is:


Notice that it took us only 3 steps to finish compared to 7 steps for the binary conversion.

Finally, the conversion to Hexadecimal:
Dividend QuotientRemainder
122710 (i.e. A)

Hence the result is:


Notice that it took us only 2 steps to finish the conversion!.

 An Important note
It takes less steps to convert from decimal to hexadecimal,

So a quick way to convert from decimal to binary is to convert first to hexadecimal and then from hexadecimal to binary,

In the example above the 7A result would have been very easily converted to its binary equivalent: 1111010.

Yet another method for converting decimal numbers to binary

As one become more experienced with the powers of two, the decimal-to-binary conversion process could become direct and fast.

First familiarize yourself with the powers of two listed in the table below:

 Powers of 2

Now to convert a decimal number to binary, the procedure is very simple:

 Procedure for converting from Decimal to Binary

  1. Determine the highest possible power of two that is less or equal to the number. For example, the highest power of two in 122d is 64 and the highest power of two in 526d is 512 and so on.

  2. Put a 1 in the bit position corresponding to the highest power of two found above. So for a highest power of two of 64, we put 1 in the seventh bit position, and for a highest power of two of 512, we put a 1 in the 10th bit position. This is now our most significant bit.

  3. Subtract the highest power of two found in step 2 above from the number.

  4. Examine the remaining number:

    If it is larger or equal than the next power of two, then put a 1 in the next bit position and subtract this power of two from the number

    If it is less than the next power of two, put a 0 in the next bit position and repeat step 3 till all bit positions are filled.

The above process is best illustrated using an example:

 Example: Converting 76d to Binary

  1. The highest power of 2 less or equal to 76 is 64, hence the seventh (MSB) bit is 1:


  2. Subtracting 64 from 76 we get 12.

  3. 12 is less than the next power of 2 which is 32, hence the sixth bit position is 0:


  4. 12 is still less than the next power of 2 which is 16, hence the fifth bit position is 0:


  5. 12 is greater than the next power of 2 which is 8, hence the fourth bit position is 1:


  6. We subtract 8 from 12 and get 4, which will be compared to the next power of 2.

  7. 4 is equal to the next power of 2 which is 4, hence the third bit position is 1:


  8. Subtracting 4 from 4 yield a zero, hence all the left bits are set to 0 to yield the final answer: