Thread: Is it an error or am i wrong

1. Is it an error or am i wrong

Hey guys im novice c prog and i am reading the book "jumping into c++".
Im in the first few pages and i came across a problem.
attached is a screenshot of my problem.
Is it a printing mistake or have i messed up?
This is pg 59 of the " jumping into C++"
Im really enjoying this book.
Isn't it supposed to be 264 because a double is 8 bytes (8bytes x 8bits=64bits)

2. But those 64 bits are split up into a significand and exponent.

Yes it can store numbers up to 10^308, but it's only the first 15 digits which are actually stored within those 8 bytes.
The rest of the number isn't stored at all (hence significant digits).

It's a trade-off between a very large dynamic range and a small compact storage format.

It does however mean you have to be really careful when combining numbers with very different exponents.
10^100 + 1 will still be 10^100. You see, 1 is just far too small to be of any significance to 10^100.

If you really wanted to store ALL the digits of 10^308 in complete accuracy, you would need a number containing 128 bytes of memory, not 8 bytes.
Such things are possible with a multi-precision library, but you have to do some work yourself.

3. oh okok i get it now !!

thank you.

4. You are right, though, there is a typo in the book.

There are 2^64 possible bit patterns that can be stored in 8 bytes, so there cannot be more than 2^64 different double precision floating point numbers. In fact there are slightly less since not every bit pattern represents a legal value.

The number they print out, though, IS 2^64 - they had the expanded form correct but the simpler form mistyped.