# Why the hexadecimal numbers can be converted directly into binary numbers so cleanly?

Suppose we have F9 hex. If we want to convert it into binary, we just replace the hexadecimal numbers with their corresponding binary numbers. Like 9 has1001 in binary and F has 1111 in binary. By combining it becomes 1111 1001. But why does it give the right answer when we convert both into decimal number. Why we can't convert any base system into another base system which does not come in its power? As we form a base-3 number system and a base-9 number system. As 9=3^2 so two digits of base-3 can be represented by a single base-9 digit. But why this happens?

• Because $2 \mid 16$. – copper.hat Feb 8 '18 at 17:13
• Same reason why for example 2 0 1 8 in base 10 is 20 18 in base 100=10^2. – dxiv Feb 8 '18 at 17:15
• @copper.hat 2 being a factor of 16 is definitely not sufficient. Try it with 5 and 10. – Mjiig Feb 9 '18 at 9:54
• @Mjiig: You are correct, it was meant to provoke thought, not to be an answer, and I meant to write $2^4 \mid 16$. – copper.hat Feb 9 '18 at 19:54

Hint: a sequence of digits $a_n \dots a_0$ in base $g$ corresponds to the natural number $a_n \cdot g^n + \dots + a_0 \cdot g^0.$ What happen if we consider this number in a base $h$ such that $g=h^k$?
Anyway, even with $2$ and $16$ one needs to be careful: for instance, $F=1111$ and $7=111$ in base $2$, but $F7 = 11110111$ and not $1111111$. Can you see why this happens?
Suppose we have a number $X$ which is written as $X_2X_1X_0$ in hexidecimal. Then we have $X = 16^0X_0 + 16^1X_1 + 16^2X_2$.
$16 = 2^4$ so we rewrite that as $X = 2^0X_0 + 2^4X_1 + 2^8X_2$. Now let's suppose $X_2$ can be written $x_3x_2x_1x_0$ in binary, then $X_2 = 2^3x_3 + 2^2x_2 +2^1x_1 +2^0x_0$. Substituting we get $$X = 2^0X_0 + 2^4X_1 + 2^8(2^3x_3 + 2^2x_2 +2^1x_1 +2^0x_0)$$ $$X = 2^0X_0 + 2^4X_1 + 2^{11}x_3 + 2^10x_2 +2^9x_1 +2^8x_0$$
If you repeat that process for $X_0$ and $X_1$ you'll get an expression for $X$ entirely in terms of powers of two, just by substituting in the binary expansions of its digits in hexidecimal.