# How to convert from scientific binary form to decimal

I have the following number written in binary scientific notation: $$1.1111111111111111111111111111111111111111111111111111\cdot2^{1023}$$ There are 53 ones in the binary number. I know that this number when converted into decimal system is represented as $$1.7976931348623157\cdot10^{308}$$ I can't see to figure out how to do the conversion without going through the algorithm of converting binary to decimal using multiplication by two and adding current digit, as in: $$111_2 = 7_{10}$$ $$2\cdot(2\cdot((2\cdot0)+1)+1)+1=7$$

• $2^{1023}\cdot\sum\limits_{n=0}^{52}\left(\frac12\right)^n=2^{1023}\cdot\frac{2^{53}-1}{2^{52}}=2^{1024}-2^{971}$ – barak manos Oct 6 '16 at 19:53

The exponents go negative to the right of the decimal. The first one to the right of the decimal is in the $2^{-1}$ place, the next one is in the $2^{-2}$ place, and so on.

So, for example, $1.111_2 = 2^0 + 2^{-1} + 2^{-2} + 2^{-3} = 1.875 = 2 - 0.125 = 2-2^{-3}.$

Now just apply the same argument to your number to give

$$(1.\underbrace{111.....1}_{52\text{ times}})_2 = 2 - 2^{-52}.$$

Then it's just manipulating the exponents in the $2$s:

$$(2^1 - 2^{-52})\cdot2^{1023} = 2^{1024} - 2^{971} \approx 2^{1024} \doteq 1.79769313 \cdot 10^{308}.$$

• thanks a lot for clear explanation, can you please also tell me why you write $2^{1024}-2^{971}\approx2^{1024}$? – Max Koretskyi Oct 7 '16 at 10:01
• $2^{1024}$ is about $10$ quadrillion times larger than $2^{971}$, so out to $9$ significant figures the smaller term changes nothing. Just me trying to save a bit of time calculating the final number but also acknowledge the other term. The exact answer contains both terms and you can calculate it to all of the digits if you need. – John Oct 7 '16 at 14:00
• I see, thanks for the explanation. I also don't understand why $2^{1024}$ is equal to the decimal number with zeros. I can't see how any power of 2 can produce the number with trailing zeros. Can you please clarify that as well? – Max Koretskyi Oct 7 '16 at 14:04
• It doesn't. All of the digits are here. If you need an exact value, there it is. But for a large range of applications, this kind of precision isn't needed. So floating point representation give you so many significant figures (like $15$) and a certain range of exponent to deal easily with many common situations. – John Oct 7 '16 at 15:22
• I got it, thanks a lot for you elaborate explanation! it's pity I can't upvote multiple times :) Maybe you can add this information in your answer – Max Koretskyi Oct 7 '16 at 15:32