Then where comes the 8 decimals of numbers come from other then taking
a wild stab in the dark and guessing number(s)?
As he said, it's probably simply padded with zeros. (And there are no
"decimals" there at all, except in the string representation for the literal
you type in and for the values printed out in your debugger or using cout.)
If I look at the memory for those in a program compiled under CodeWarrior
and running in OS X on the Mac, then here's what I see:
actual float value in hex: 0x3ff19999a0000000
actual double value in hex: 0x3ff199999999999a
float value as decimal: 1.100000023841858
double value as decimal: 1.100000000000000
You can see that the "extra" [hex] digits are set to zeros. They're not
used when the value is treated as a float, only if you later treat it as a
double. But the hardware has to store something there, because the size of
the register is big enough to hold a double, and so the compiler creates a
binary value that's as near as it can get to the desired decimal value, and
the rest of the bits are set to zero.
That decimal portion of the float "23841858" is not "randomly" picked, it's
the decimal equivalent of the binary value that gets stored, and it's that
binary value which has less precision than the double. In this case, the
hardware stores a value that is actually a little larger than the desired
value. (In some cases, it may be smaller.)
-Howard