&gt; It is misleading to print more decimal digits out of a double than DBL_DIG<p>If you want round-trip conversion for all `double` numbers, i.e. from `double` to text and back, you need 17 digits of precision (%.17g).<p>Likewise, if you want round-trip conversion for all `float` number, you need 9 digits (%.9g).<p>The reason for this is that even though these types can really only reliably give 15 and 6 digits of precision, some of the numbers they can represent are closer to each other than that.<p>In C++, you can get the former limit using std::numeric_limits&lt;double&gt;::digits10, and the latter using std::numeric_limits&lt;double&gt;::max_digits10.<p><a href="http:&#x2F;&#x2F;en.cppreference.com&#x2F;w&#x2F;cpp&#x2F;types&#x2F;numeric_limits&#x2F;max_digits10" rel="nofollow">http:&#x2F;&#x2F;en.cppreference.com&#x2F;w&#x2F;cpp&#x2F;types&#x2F;numeric_limits&#x2F;max_di...</a>