Boost C++ Libraries: Ticket #7785: karma real generator limits precision to digits10 no matter exponent https://svn.boost.org/trac10/ticket/7785 <p> The real_inserter::call_n method here is limiting the user-provided precision by the <a class="ext-link" href="http://svn.boost.org/svn/boost/trunk/boost/spirit/home/karma/numeric/detail/real_utils.hpp"><span class="icon">​</span>http://svn.boost.org/svn/boost/trunk/boost/spirit/home/karma/numeric/detail/real_utils.hpp</a> </p> <p> But that value is later used to determine how many decimal digits to print, independently on where the first non-zero digit is. This means overlimiting the actual number of significant digit for no evident reason. </p> <p> The user provided ::precision() function has access to the full number and thus can judge when to provide more or less precision depending on magnitude. Why not trusting that ? </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7785 Trac 1.4.3 strk@… Tue, 11 Dec 2012 10:55:19 GMT <link>https://svn.boost.org/trac10/ticket/7785#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7785#comment:1</guid> <description> <p> For reference, the problem showed up here: <a class="ext-link" href="https://github.com/mapnik/mapnik/pull/1632"><span class="icon">​</span>https://github.com/mapnik/mapnik/pull/1632</a> where we're trying to get an output comparable with that of iostream with setprecision(16) </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Thu, 13 Dec 2012 10:50:26 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7785#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7785#comment:2</guid> <description> <p> On further analysis I found out that the "fraction_part" function does not even get more than 13 significant digits when the number is lower than 10e-3, so there's nothing an overridden fraction_part method could do </p> </description> <category>Ticket</category> </item> <item> <author>Sandro Santilli <strk@…></author> <pubDate>Thu, 13 Dec 2012 12:44:11 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7785#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7785#comment:3</guid> <description> <p> The problem is in call_n, where fractional part is normalized even if the format flag is requesting fixed precision, despite the comment above (saying normalization is only needed for scientific notation). </p> <p> This patch would fix my case: </p> <pre class="wiki">--- real_utils.hpp.000 2012-12-13 13:42:01.000000000 +0100 +++ real_utils.hpp 2012-12-13 13:43:02.000000000 +0100 @@ -85,5 +85,5 @@ // get correct precision for generated number unsigned precision = p.precision(n); - if (std::numeric_limits&lt;U&gt;::digits10) + if (std::numeric_limits&lt;U&gt;::digits10 &amp;&amp; !(Policies::fmtflags::fixed &amp; flags)) { // limit generated precision to digits10, if defined </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Joel de Guzman</dc:creator> <pubDate>Thu, 13 Dec 2012 14:32:24 GMT</pubDate> <title>owner changed https://svn.boost.org/trac10/ticket/7785#comment:4 https://svn.boost.org/trac10/ticket/7785#comment:4 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Joel de Guzman</span> to <span class="trac-author">Hartmut Kaiser</span> </li> </ul> Ticket Joel de Guzman Sun, 14 Mar 2021 19:56:04 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/7785#comment:5 https://svn.boost.org/trac10/ticket/7785#comment:5 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> fixed in <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/586" title="#586: Patches: iostreams // file_descriptor::seek BUG on files &gt; 4 GB (closed: fixed)">#586</a> <a class="ext-link" href="https://github.com/boostorg/spirit/pull/586"><span class="icon">​</span>https://github.com/boostorg/spirit/pull/586</a> </p> Ticket