# Number system conversions

I am an Electrical Engineering student but my question is related to number systems, more specificaly to conversions between octal, hexadecimal and binary systems. I know the rules of conversions but I don't get one thing: why is it possible to convert hexadecimal or octal to binary by just substituting sequences of 3 or 4 digits to corresponding digit in the given system? I know that with a string of length three you can uniquely represent one member of a set with eight members. But after this kind of substitution this two representations must also have one important additional property: the sum of individual digits multiplied with the radix to the power of the digits weigth must be equal for both representations.

p.s. I apologize in advance for not using mathematical formulas as I don't know how :) Thanks.

$$\qquad\ \ \ n = d_0 + d_1 b + d_2 + (d_3 + d_4 b + d_5 b^2) b^3 + \cdots,\ 0\le d_i < b\$$ is a radix $$b^{\large 3}$$ expansion

$$\iff n = d_0 + d_1 b + d_2 + d_3 b^3 + d_4 b^4 + d_5 b^5 + \cdots,\ \ 0\le d_i < b\$$ is a radix $$b$$ expansion

Indeed, both are valid radix expansions, so equality follows by the uniqueness of such expansion.

For any integer $$n$$ we have

$$n=8\lfloor \frac{n}{8} \rfloor + 4\left(\lfloor \frac{n}{4} \rfloor \mod 2 \right) + 2\left(\lfloor \frac{n}{2} \rfloor \mod 2 \right) + (n \mod 2)$$

You can regard the last 3 terms as a binary encoding of the rightmost digit in the octal expansion of $$n$$, or as being the rightmost three digits in the binary representation of $$n$$ itself. You get the same three values whichever way you look at it. So, for example,

$$(13 \mod 8)_2 = 5_2 = 101$$

and

$$(13_2) \mod 8 = 1101 \mod 8 = 101$$

This is because $$8$$ is a power of $$2$$. The same thing works for hex, but with $$4$$ binary digits instead of 3, because $$16 = 2^4$$.