Trying to understand the fundamentals of binary rather than just following steps, I wanted to know why do we multiply by 2 to convert a decimal (0.5, 0.25) to a binary and why do we divide by 2 when we want to convert a whole number (200) by 2? Obviously, it works but how ?
Take the following example:
Convert $200_{10}$ to binary:
Solution:
D > B | Remainder
-------------------------------------
200 / 2 = 100 | 0
100 / 2 = 50 | 0
50/2 = 25 | 0
25/2 = 12 | 1
12/2 = 6 | 0
6/2 = 3 | 0
3/2 = 1 | 1
1/2 = 0 | 1
By taking the remainder from bottom-to-top
$200_{10} = 11001000_2$
Why this method works ? In other words, what's the secret behind the division by $2$ ?
Now converting decimals (e.g. 0.5, 0.25) to binary:
Now Suppose we have a decimal like $0.25$ and we want to convert it to binary, one of the method which I know goes like this:
Multiplying the decimal by 2 repeatedly:
0.25 * 2 = {0}.50 | {0}
0.50 * 2 = {1}.00 | {1}
0.00
--------------------------
.01
0.01
For more details about the above method: Decimal to binary conversion with fraction
You can see the the two operations are reversed, to convert a whole number to a binary we divide by $2$ and to convert a fraction (decimal) we used multiplication. Add to that the order in which we take the result from bottom-to-top and from top-to-bottom. How that works?
(Why division used to convert whole numbers to binary and why multiplication used to convert decimals (e.g. 0.25) to binary?)
This all boils down to the concept of positional notation. For example, consider the number $19$ (in base $10$), which in base $2$ becomes $10011$. To understand why, you need to understand what this notation mean: $$ 19_{10} = \color{lime}{1}\color{green}{0}\color{olive}{0}\color{grey}{1}1_2 := 1 \cdot 2^0 + \color{grey}{1} \cdot 2^1 + \color{olive}{0} \cdot 2^2 + \color{green}{0} \cdot 2^3 + \color{lime}{1} \cdot 2^4 $$ So, how can we perform this conversion? Observe that repeatedly applying the distributive property of the product over the sum we have $$ \begin{align} 19_{10} &= 1 + 2 \cdot \color{grey}{1} + 2^2 \cdot \color{olive}{0} + 2^3 \cdot \color{green}{0} + 2^4 \cdot \color{lime}{1} \\ &= 1 + 2 \cdot (\color{grey}{1} + 2 \cdot \color{olive}{0} + 2^2 \cdot \color{green}{0} + 2^3 \cdot \color{lime}{1}) \\ &= 1 + 2 \cdot \big(\color{grey}{1} + 2 \cdot (\color{olive}{0} + 2 \cdot \color{green}{0} + 2^2 \cdot \color{lime}{1})\big) \\ &= 1 + 2 \cdot \Big(\color{grey}{1} + 2 \cdot \big(\color{olive}{0} + 2 \cdot (\color{green}{0} + 2 \cdot \color{lime}{1})\big)\Big) \end{align} $$ then you can see that the remainder $r_0$ of $19$ when divided by $2$ is its first binary digit. Then we can perform division by $2$ with remainder on $(19 - r_0)/2$ to find the next digit, $r_1$, and so on.
The case of fractional numbers is similar, after you observe that $$ 0.abc\dotsc_2 := a \cdot 2^{-1} + b \cdot 2^{-2} + c \cdot 2^{-3} + \dotsb $$
Note that this is not the only possible way to perform this conversion, but it is certainly quite an efficient way. Further, by analogy you can tweak this algorithm to write a number in any integer base $b > 1$, with the integers between $0$ and $b-1$ (included) as digits!
Update: Since this was asked in the comments, here's a quick way of finding the binary digits of a given number's fractional part.
First note that if $f$ is the fractional part, then $0 \leq f < 1$. Furthermore, $0 \leq 2f < 2$, and if you look at the above equation for $0.abc\dotsc_2$ you'll see that the integer part of $2f$ is none other than $a$, the first digit of the binary expansion! If you now take out $a$, you can repeat the process, because the same equation tells us that the integer part of $2(2f-a)$ is $b$. In other words, here's the algorithm:
For example, consider the number $\frac{5}{8}=0.625_{10}$. Then:
In the end, $0.625_{10} = 0.101_{2}$.
For a number with infinite binary expansion, consider $1/3 = 0.333\dotsc_{10}$. Then:
Since we are left with $\frac{1}{3}$, which is what we started with, we can conclude that the expansion is periodic, thus $0.333\dotsc_{10} = 0.0101\dotsc_{2}$.