# Why are these two conversion methods (base 10 to base 2) equivalent

I've come across two methods for converting a base 10 number into its base 2 equivalent. I want to know why they are equivalent.

Method 1: We're given a number $N$ to convert into binary

1) Find the greatest power of 2, which when subtracted from $N$, leaves a positive difference.

2) Let the difference be denoted as $N_1$

3) Now find the greatest power of 2, which when subtracted from $N_1$, produces a positive difference.

4) Continue this process until the difference is $0$.

5) The binary equivalent is obtained from the coeffiecients of a power series that forms the sum of the components. $1$s appear in the binary number in the positions for which terms appear in the power series, and $0$s appear in all other positions.

Example, converting $625$ (Base 10) to base 2.

625 - 512 = 113 = $N_1$

113-64 = 49 = $N_2$

49 - 32 = 17 = $N_3$

17 - 16 = 1 = $N_4$

1 - 1 = 0 = $N_5$

650 (Base 10) = $2^9 + 2^6 + 2^5 +2^4 + 2^0 = 1001110001_2$

Method 2:

1) Divide the base 10 number by 2

2) Record its remainder beside the quotient, then divide the quotient by 2.

3) Continue this process until the quotient is 0. Then take all the remainders from bottom to top, line them up, and you have the binary number

Example:

Convert 17 to base 2.

17/2 = 8R1

8/2 = 4R0

4/2 = 2R0

2/2 = 1R0

1/2 = 0R1

Our binary equivalent of 17 is: $10001_2$

We could actually create a more general method that encompasses both and explains why they are equivalent; in particular, choose some $n$, which we will convert to binary. Now, choose some $i$ and divide $n$ by $2^i$, recording the remainder. More precisely, find the integers $a$ and $b$ such that: $$n=a2^i+b.$$ So $a$ is the quotient and $b$ is the remainder. In binary, $n$ will be the binary representation of $a$ followed by the representation of $b$ (where $b$ is written with $i$ digits, possibly including leading zeros). For instance, we can convert 17 by noting that it is $2\cdot 2^3 + 1$. So, we write the quotient, 2, in binary as $10_2$ and the remainder, 1, using 3 digits as $001_2$. Then, when we join the two, we get: $$17=10001_2$$ which is correct.
It's easy to prove the correctness of this general method because $$n=a\cdot 2^i+b$$ in binary looks like: $$n=a\cdot \underbrace{10\ldots 0_2}_{i \text{ zeros}}+b$$ and, just like multiplying by 10, or 100 in base 10, when we multiply by $a$ we shift its digits $i$ places to the left. Then, since $b$ clearly has no more than $i$ digits (being less than $2^i$), there are no places where given bit of both $a2^i$ and $b$ is non-zero - thus their sum is the same as appending the strings.
Your second method is what happens when you express $$n = a\cdot 2^1 + b$$ And you iterate the method on $a$ to find its binary expansion, essentially reading off one bit $b$ at a time, since $b$ is always either 0 or 1. That is, we first find that $17 = 8\cdot 2 + 1$, so 17 in base 2 is 8 in base two, followed by "1". Then we convert 8 to base two as $8=4\cdot 2+0$, so 8 is 4 in base two followed by a zero. Your first method is what happens when you take the largest $i$ such that $n\geq 2^i$ and set $$n = a\cdot 2^i + b$$ where $a$ is always $1$ - this essentially reads off the most significant bit each time and is used recursively to find the value of $b$. But, since the general method of "splitting" the string at some arbitrary power of two works, it is clear these methods will both yield the correct (and ergo same) answer.
This step is the equivalent of having divided $N$ by $2$ a number of times and getting the remainder at step $k$, where this $k$ is that "greatest power of $2$ which..."