std::numeric_limits<double>::digits10 = number of digits on the right or left to the radix point? [closed]

对着背影说爱祢 提交于 2019-12-08 14:12:23

问题


http://en.wikipedia.org/wiki/Double-precision_floating-point_format say that double can handle 16 digits of precision to the right part of the number, is digits10 show this number ?


回答1:


Actually it's just the number of meaningful digits. Point. You can have 12345678901234.5 or 0.0000123456789012345.




回答2:


std::numeric_limits<T>::digit10 is the number of decimal digits you can get back when converting a string with a decimal value to T and back to a string again. The count starts at the most significant non-zero digit, independent of where the decimal point is located (as long as you don't conflict with the range restrictions of T, of course). That is, leading and trailing zeros don't matter.



来源:https://stackoverflow.com/questions/13103304/stdnumeric-limitsdoubledigits10-number-of-digits-on-the-right-or-left-to

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