Boost C++ Libraries: Ticket #11608: boost::spirit::double_ fails with large numbers https://svn.boost.org/trac10/ticket/11608 <p> Since 1.59.0, spirit fails to parse large doubles when they are written out. </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&lt;boost/spirit/include/qi_real.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;iostream&gt;</span><span class="cp"></span> <span class="kt">int</span> <span class="nf">main</span><span class="p">()</span> <span class="p">{</span> <span class="c1">// 2^100, exactly representable as double</span> <span class="k">auto</span> <span class="n">str</span> <span class="o">=</span> <span class="s">&quot;1267650600228229401496703205376&quot;</span><span class="p">;</span> <span class="kt">double</span> <span class="n">f</span><span class="p">;</span> <span class="n">boost</span><span class="o">::</span><span class="n">spirit</span><span class="o">::</span><span class="n">qi</span><span class="o">::</span><span class="n">parse</span><span class="p">(</span><span class="n">str</span><span class="p">,</span> <span class="n">str</span> <span class="o">+</span> <span class="n">strlen</span><span class="p">(</span><span class="n">str</span><span class="p">),</span> <span class="n">boost</span><span class="o">::</span><span class="n">spirit</span><span class="o">::</span><span class="n">double_</span><span class="p">,</span> <span class="n">f</span><span class="p">);</span> <span class="c1">// The following code line prints</span> <span class="c1">// 1.26765e+30 (with boost 1.58.0, correct)</span> <span class="c1">// -9.25596e+61 (with boost 1.59.0)</span> <span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o">&lt;&lt;</span> <span class="n">f</span> <span class="o">&lt;&lt;</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span> <span class="k">return</span> <span class="mi">0</span><span class="p">;</span> <span class="p">}</span> </pre></div></div> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11608 Trac 1.4.3 Tobias Reh <treh@…> Tue, 01 Sep 2015 09:50:54 GMT component changed; owner set https://svn.boost.org/trac10/ticket/11608#comment:1 https://svn.boost.org/trac10/ticket/11608#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Joel de Guzman</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">spirit</span> </li> </ul> Ticket Tobias Reh <treh@…> Wed, 02 Sep 2015 13:49:19 GMT summary changed https://svn.boost.org/trac10/ticket/11608#comment:2 https://svn.boost.org/trac10/ticket/11608#comment:2 <ul> <li><strong>summary</strong> <span class="trac-field-old">boost::spirit::double_ yields wrong result</span> → <span class="trac-field-new">boost::spirit::double_ yields fails with large numbers</span> </li> </ul> <p> Actually the line </p> <div class="wiki-code"><div class="code"><pre><span class="n">boost</span><span class="o">::</span><span class="n">spirit</span><span class="o">::</span><span class="n">qi</span><span class="o">::</span><span class="n">parse</span><span class="p">(</span><span class="n">str</span><span class="p">,</span> <span class="n">str</span> <span class="o">+</span> <span class="n">strlen</span><span class="p">(</span><span class="n">str</span><span class="p">),</span> <span class="n">boost</span><span class="o">::</span><span class="n">spirit</span><span class="o">::</span><span class="n">double_</span><span class="p">,</span> <span class="n">f</span><span class="p">);</span> </pre></div></div><p> returns false with boost 1.59.0. So it does not "yield a wrong result" but fails, and I have updated the summary accordingly. </p> <p> It is still a regression. </p> Ticket Tobias Reh <treh@…> Wed, 02 Sep 2015 13:49:52 GMT summary changed https://svn.boost.org/trac10/ticket/11608#comment:3 https://svn.boost.org/trac10/ticket/11608#comment:3 <ul> <li><strong>summary</strong> <span class="trac-field-old">boost::spirit::double_ yields fails with large numbers</span> → <span class="trac-field-new">boost::spirit::double_ fails with large numbers</span> </li> </ul> Ticket Joel de Guzman Wed, 02 Sep 2015 14:38:40 GMT <link>https://svn.boost.org/trac10/ticket/11608#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11608#comment:4</guid> <description> <p> I'll have a look over the weekend. Thanks for the report. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Joel de Guzman</dc:creator> <pubDate>Thu, 25 Apr 2019 11:43:49 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11608#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11608#comment:5</guid> <description> <p> Fixed in <a class="ext-link" href="https://github.com/boostorg/spirit/commit/be7640bd692684b2fd7532745ddd6343e551744d"><span class="icon">​</span>https://github.com/boostorg/spirit/commit/be7640bd692684b2fd7532745ddd6343e551744d</a> tests added </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Joel de Guzman</dc:creator> <pubDate>Thu, 25 Apr 2019 11:44:22 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/11608#comment:6 https://svn.boost.org/trac10/ticket/11608#comment:6 <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> Ticket