Could it be something like the actual value of DBL_MAX
isn't exactly representable in exponential notation with 16 decimal places (say the decimal value is very slightly larger than the two based represenation) but initializing a double
with the DBL_MAX
will nevertheless set the correct value (due to rounding). std::istringstream
may be a little bit more pickish.
EDIT: Actually I found that the value of DBL_MAX
in my compiler is 1.7976931348623158e+308 which works fine for me to stream. Your number is rounded and slightly larger, hence the failure.
EDIT2: The exact value of DBL_MAX
in decimal form is given by (2 ^ (1023 - 52)) * (2 ^ 53 - 1)
which isn't representable with 16 decimal places.