I used to think that there is only one to convert to a higher base ie: https://math.stackexchange.com/a/111158/407302
If we want to convert $(1200)_3$ to $(45)_{10}$ we do the following:
$1\cdot 3^3 + 2\cdot 3^2 + 0 + 0 = 27 + 18 = 45$
But I have found a weird way of by multiplying only a single power of the "incoming base" from the right.
It goes in the following way:
- Start with $[0,0]$
- Add 1 to it -> $[0,1]$ $1$ is from the left hand digit of $1200$
- Multiply with 3 (base) and add 2 (ie. 2 from $1200$, second digit) we get $[0,5]$
- Multiply with 3 (base) and add 0 (ie. 0 from $1200$, third digit) we get $[1,5]$
- Multiply with 3 (base) and add 0 (ie. 0 from $1200$, last digit) we get $[4,5]$
Here is the same calculation but in base-16(hex):
[0,0] + 1 = [0,1]
[0,1] X 3 + 2 = [0,5]
[0,5] X 3 + 0 = [0,F]
[0,F] X 3 + 0 = [2,D] -> 2D
Disclaimer: I have arbitrarily taken the construct $[0,0]$ represent the result because this method is taken from the Java library(BigInteger) which uses arrays to convert really large integers to an internal representation of base $2^{32}$. You can try it with an arbitrary length of zeroes too.
I have no idea why this method works.
Is this methods only valid for when converting to a base higher than the base of the given number ?
I have some intuition about why the "normal" method works : each place in the number from left to right denotes how many times a the base has "overflown", hence we add a digit to the left and reset the digit to the right.
But this I am unable to figure out the arithmetic.
How does this method work ? Why does it work ?
Am I only one impressed by this ? Am I missing something really basic ?