Why multiplying by base b works when converting fractions from one base to another?

224 Views Asked by At

Suppose we have a decimal like 0.25 and we want to convert it to binary, one of the methods 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  

Why does this work?

3

There are 3 best solutions below

0
On BEST ANSWER

Let $r$ be a real number between $0$ and $1$. The first digit in the base $b$ representation of $r$ is the number of times $1/b$ goes into $r$ -- or, to be more precise, it's the largest whole number $n_1$ with the property that $$n_1\cdot\frac{1}{b} \le r$$ This condition is equivalent to $$n_1 \le br$$ Another way of saying this is that the first digit is the largest whole number less than or equal to $br$. So to find the first digit of the base $b$ representation, multiply $r$ by $b$ and take the integer part.

Similarly, the second digit of the base $b$ representation of $r$ is the largest whole number $n_2$ with the property that $$n_2 \cdot \frac{1}{b^2} \le r - \frac{n_1}{b}$$ Equivalently, $$n_2 \le b^2 r - b\cdot n_1$$ Therefore you can find the second digit by computing $b^2 r - b\cdot n_1$ and just keeping the integer part. This continues for each digit in the base $b$ expansion.

0
On

If the number is more than $\frac 12$ you will get a $1.xxx$ when you multiply by $2$. You put that $1$ on your decimal to indicate the value of $\frac 12$. Then you take what's left and do it again. If what is left was is greater than $\frac 12$ then that part was originally greater than $\frac 14$. You get a $1$ at this point and so that one indicates $\frac 14$ and so one.

If the numbers were less than $\frac 12$ you get a $0$.

0
On

When converting integers, you divide repeatidly by $b$ until you have nothing left to be divided. When converting fractions, you multiply repeatidly by $b$ until you are left with zeros (or your digits start cycling). Same insight, but in opposite direction.