strtod 更改最后一位数字
有人可以向我解释发生了什么事吗?
double dbl = stdtod("9999999999999999", NULL);
我得到的值:9999999999999998
而不是:9999999999999999
我不明白为什么会发生这种情况,在MSDN中,指定最大双数是1.7976931348623158E+308
,所以它不能溢出。
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这不是溢出,而是浮点工作原理的问题。有效数字的数量是有限的,在溢出之前就已经超出了。此链接已被多次听到,但请查看此
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