strtod change last digit

159 Views Asked by At

someone can explain to me what is happening?

double dbl = stdtod("9999999999999999", NULL); 

I got the value: 9999999999999998
and not: 9999999999999999

I don't understand why this happen, in the MSDN, is specified that the max double number is 1.7976931348623158E+308, so it can't be a overflow.

Thanks

1

There are 1 best solutions below

0
On

Its not an overflow its an issue with how floating point works. You have a limited nubmer of significant digits that is exceeded long before you get an overflow. This has been linked hear many times but check out this