1
$\begingroup$

I'm attempting to find a better way of converting arbitrary based numbers.

I've been taught to first convert the number, lets say 235 (base7)to its equivalent in decimal or base 10.

 2       3       5

 2*7^2 + 3*7^1 + 5*7^0

 98    + 21    + 5

 = 124 (dec)

Then through the process of long division, convert it to a different base equivalent number.

124(dec) -> x(base 3)

 124 / 3 =  41 + 1/3

 41 / 3  =  13 + 2/3

 13 / 3  =   4 + 1/3

 4 / 3   =   1 + 1/3

 1 / 3   =   0 + 1/3

Then by reading the remainders from the bottom up the result in base3 is

 1 1 1 2 1

Its doable, but this method requires a bit of time to preform, and it can become difficult when the numbers become large.

For number bases of the power of 2, 2 4 8 16... the conversion between these numbers is easy to preform with number grouping.

To convert 711 (oct) to (base 4) its possible to do so by converting to bin, then to the base. using a group size of 2, 2^2 = 4

      7    1    1

    111  001  001


 | 1|11 |00|1 0|01|

  1  11  00  01  01

  1  3   0   1   1

    1 3 0 1 1 (base 4) = 711 (oct)

Or to convert 711(oct) to hex its the same process but with a group size of 4. using a group size of 4, 2^4 = 16

      7    1    1

    111  001  001


 | 1|11  00|1 001|

   1  1100  1101

  1  12  5  = 1C9 (hex) = 711(oct)

This process is easier, faster, and more reliable.

I want to know if there is a similar process for converting arbitrary bases.

$\endgroup$
  • $\begingroup$ It's easy to convert between bases $a$ and $a^k$, so base $16$ to base $2$ then to base $8$ is easy. For other conversions .... good luck! $\endgroup$ – Lord Shark the Unknown May 3 '18 at 4:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.