I have a very simple question about double precision.
Assume that $x=10^{20}+300$.
What is the double precision representation of $x$?
Now the answer is $10^{20}$. What I don't understand is,why?
After all,the largest number when using DP is about $10^{307}$, so why do we lose that $300$?
In double precision, the next representable number after $10^{20}$ is $10^{20} (1+\varepsilon)$, for $\varepsilon = 2^{-52} \approx 2.2204 \cdot 10^{-16}$. Now $$ 10^{20} (1+\varepsilon) > 10^{20} + 2 \cdot 10^{4} = 10^{20} +20000 > 10^{20} + 300 $$ Therefore, $10^{20}+300$ is not representable. The closest representable number is $10^{20}$ and so $10^{20}+300=10^{20}$ in floating point.