This is probably a very basic question but nonetheless I choked when I got in a math for programmers class. I was taught how to convert from base to base but I have no idea how to convert fractions to decimals in bases other than base 10.
How to compute 1/7 in base 8?
1k Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail AtThere are 4 best solutions below
On
Jimmy K4542 gives a fine answer for the specific case, but suppose you wanted $1/37$ in base $8$? Remember that the first place after the point is $\frac 18$, the second is $\frac 1{8^2}$, the next $\frac 1{8^3}$ and so on. Multiply $\frac 1{37}$ by $8$ and take the integer part, which is zero. There is therefore a zero in the eighths place. Multiply again by $8$, getting $\frac {64}{37}$ and take the integer part, which is $1$. The value in the sixty-fourths place is a $1$. Take the fractional part, which is $\frac {64-37}{37}=\frac {27}{37}$, multiply by $8$, getting $\frac {216}{37}$, take the integer part, which is $5$, which is the next place. Then what remains is $\frac {31}{37}$ and on you go.
On
Working in base $B$, we want to find the radix representation of a fraction $\frac{a}{b} $, and we're given that $0 < \frac{a}{b} < 1$.
$$\begin{align} \frac{a}{b} & = 0.d_1d_2d_3d_4\dots\\ \frac{Ba}{b} & = d_1.d_2d_3d_4\dots\\ \left\lfloor\frac{Ba}{b}\right\rfloor & = d_1\\ \frac{Ba}{b} - d_1 & = 0.d_2d_3d_4\dots\\ \frac{Ba - d_1b}{b} & = 0.d_2d_3d_4\dots\\ \end{align}$$
And now we have another fraction between $0$ and $1$ and we can find out the next digit in the same way.
Hint: Using the formula for the sum of an infinite geometric series, we have: $\dfrac{1}{7} = \dfrac{1}{8-1} = \dfrac{\tfrac{1}{8}}{1-\tfrac{1}{8}} = \dfrac{1}{8}+\dfrac{1}{8^2}+\dfrac{1}{8^3}+\dfrac{1}{8^4}+\cdots$