-1

Let us take the number $32$ in base $4$ for our example. In hexadecimal it is $E$, but according to my way it ends up being $32$, which is incorrect. I take the numbers in pairs of $2$, because $4^2=16$, however this doesn't seem to work the same way it does with $2^n$. The problem is $32$ is larger than $16$, but it is also given in base $4$, not in decimal, which further complicates this. I could convert the number to binary and then continue to hexadecimal from there, but I want to know the way to convert numbers from base $n$ to base $n^x$.

Hans Hüttel
  • 4,271
  • Every block of two digits in base $\ 4\ $ (if we go from the right to the left) corresponds with a digit in base $\ 16\ $. If we have a single digit at the beginning, we also have this digit in base $\ 16\ $ – Peter Mar 10 '20 at 18:50
  • 3
    What is the problem? $32_4 = E_{16}$. Translation just isn't "one digit at a time". Like you's have to memorize the table $000_2 = 0_8, 001_2 = 1_8, \ldots 100_2 = 4_8, \ldots, 111_2 = 7_8$. – vonbrand Mar 10 '20 at 18:52
  • 1
    I recommend that when you’re doing base conversions, you always tag the numbers with the base in which they are written. The tag is a subscript: $32_4$ is the number written with the digits $3$ and $2$ in base $4$, whereas $\mathrm E_{16}$ is a one-digit number written in hexadecimal and $16_{10}$ is ten plus six written in base ten. You can sometimes omit the subscript on base ten but never on any other base. This will remind you that $32_4$ is not the same number as $32_{10}$ and be a hint that $32_4$ might not be greater than $16_{10}.$ (In fact it is less.) – David K Mar 10 '20 at 19:36

1 Answers1

1

A base $4$ representation $$(a_n \cdots a_0)_4$$ has value $$a_n \cdot 4^n + a_{n - 1} \cdot 4^{n - 1} + \cdots + a_1 \cdot 4^1 + a_0 \cdot 4^0 .$$ To write this in base $16$, we need to rewrite this quantity as a sum of powers of $16$. But powers of $16$ are themselves powers of $4$: $$\cdots + (a_3 \cdot 4 + a_2) \cdot 16^1 + (a_1 \cdot 4 + a_0) \cdot 16^0 .$$ So, the digits of the number in base $16$ are $$\ldots, \quad a_3 \cdot 4 + a_2, \quad a_1 \cdot 4 + a_0 .$$

Informally, this says that rewrite our number in base $16$, we can convert each $2$-digit string $a_{2 m + 1} a_{2m}$ separately. (If our base $4$ representation number has an odd number $2 m + 1$ of digits, we can simply append a $0$ in the $4^{2 m + 1}$ place, since this does not change the value of the representation.) In our case, we have

\begin{align*} 00_4 &= 0_{16} \\ 01_4 &= 1_{16} \\ 02_4 &= 2_{16} \\ 03_4 &= 3_{16} \\ 10_4 &= 4_{16} \\ &\,\,\vdots \\ 21_4 &= 9_{16} \\ 22_4 &= \mathrm{A}_{16} \\ &\,\,\vdots \\ 33_4 &= \mathrm{F}_{16} .\end{align*}

So, for example, $$\color{red}{10}\color{#00bf00}{03}\color{#3f3fff}{22}_4 = \color{red}{4}\color{#00bf00}{\mathrm{3}}\color{#3f3fff}{\mathrm{A}}_{16} .$$

Travis Willse
  • 99,363