Double precision in C - printing 50 significant figures yields inaccurate values

末鹿安然 提交于 2019-12-04 12:32:26

The basics of floating-point:

http://en.wikipedia.org/wiki/Floating_point

The answer in your case 0.10 is not exactly representable in binary floating-point. Therefore, it's only accurate to about 16 digits. Yet you are trying to print it out to 50 decimal places.

If you need more accurate results that what double can offer, then you may want to check out some of the arbitrary precision libraries that are available.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!