Write $0.2$ in binary such that the relative error is less than $0.005$
I know that the requirement is that $$\frac{|0.2-x|}{0.2}\leq 0.005$$
But how does it help to find the biggest sum of power of 2 that will be less than $0.005$ ?
Write $0.2$ in binary such that the relative error is less than $0.005$
I know that the requirement is that $$\frac{|0.2-x|}{0.2}\leq 0.005$$
But how does it help to find the biggest sum of power of 2 that will be less than $0.005$ ?
You want to find a binary approximation to the decimal fraction $0.2$ to a precision of one-half of one percent, which is one part in $200$ of $0.2$ or one part in $1000$. The closest binary fraction to that requirement would be one part in $1024$. This is one part in the ninth bit to the right of the binary 'decimal' point or
\begin{eqnarray} 0.2&\approx&0\text{b}0.001100110\\ &=&\frac{1}{8}+\frac{1}{16}+\frac{1}{128}+\frac{1}{256}\\ &=&\frac{102}{512} \end{eqnarray}
\begin{equation} \frac{0.2-\frac{102}{512}}{0.2}\approx0.004<0.005 \end{equation}
In a comment, you mention that to write an integer in binary you would "start with the largest power of $2$ that is smaller than the number and then add powers."
The procedure for writing a non-integer value in binary begins just like that. "The number" in this case is $0.2$ (not $0.005$). When you find the largest power of $2$ that is less than $0.2$ you will have the first "$1$" digit of your number.
In general, unless the number you are trying to write is $m/2^n$ for some integers $m$ and $n,$ you can never write it exactly in binary. The actual binary representation of $0.2$ goes on and on for infinitely many digits (though after a while it's just the same pattern of digits over and over). Therefore this exercise has given you a condition under which you can stop writing digits.
It sounds like it is not time yet to try to learn any sophisticated method for deciding how many digits you need. It is straightforward enough to just start working out the digits one at a time. Every time you append another "$1$" digit to your answer, recalculate the decimal value of the digits you have written so far. When that number, substituted for $x,$ satisfies the equation $$\frac{|0.2-x|}{0.2}\leq 0.005,$$ then you have enough digits. Keep working out more digits until that happens.
Rather than recalculating $\frac{|0.2-x|}{0.2}$ for each new value $x,$ you may find it convenient to use the fact mentioned in one of the comments, namely, you are done when $0.199 < x < 0.201.$
recall that $5$ in binary is $101$, so when you multiply it by $3$ it becomes $15$, which is $1111$.
So the following number multiplied by $5$ is equal to $1$:
$0.\overline{0011}$, just take enough digits so that it is as precise as you need.