How do I convert a fraction in base 10 to a quad fraction (base 4)?

2.4k Views Asked by At

I am totally confused when it comes to converting fractions or floating point numbers to a different base. I have no problem converting whole numbers to any base but when it comes to fractions or decimals I'm stumped. I got this question on an assignment in a math for programmers class and the book does not cover the subject, any help will be appreciated and perhaps even reciprocated some day.

Question:1. Convert 1/7 in base 10 to a quad fraction in base 4. A quad fraction is the equivalent of a decimal fraction in base 4. The fraction may be a terminating or a non-termination fraction.

2

There are 2 best solutions below

2
On

Not the standard method but anyways: $$1/7=0.142857\cdots$$ Repedetly multiply by 4 ans see the integral part: $$\begin{array}{c|c} 4\times0.142857\equiv0.571428&0\\\hline 4\times0.571428\equiv2.285714&2\\\hline 4\times0.285714\equiv1.142857&1\\\hline 4\times0.142857\equiv0.571428&0\\\hline \cdots&\cdots \end{array}$$ So $$(1/7)_{10}=(0.021021\cdots)_{4}$$

0
On

For any arbitrary decimal $D = 0.abcdef...$, the corresponding decimal $0.\overline{b_1 b_2 b_3 b_4 b_5 b_6}_4$ is determined as following:

$b_1$ is the unique whole number such that $\frac 14b_1 \leq D < \frac 14(b_1 + 1)$

$b_2$ is the unique whole number such that $\frac {1}{16} b_2 \leq D - \frac{1}{4} b_1 < \frac {1}{16}(b_2 + 1)$

$b_3$ is the unique whole number such that $\frac{1}{64} b_3 \leq D - \frac{1}{4} b_1 - \frac{1}{16} b_2 < \frac{1}{16}(b_3 + 1)$

And so forth. This will give you an answer which is arbitrarily accurate.