Re: [Boost-bugs] [Boost C++ Libraries] #9405: boost::spirit::karma::real_generator prints a number multiplied by 10

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #9405: boost::spirit::karma::real_generator prints a number multiplied by 10
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-05-09 00:34:46


#9405: boost::spirit::karma::real_generator prints a number multiplied by 10
-------------------------------------+---------------------
  Reporter: Josef Zlomek <josef@…> | Owner: hkaiser
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: spirit
   Version: Boost 1.49.0 | Severity: Problem
Resolution: | Keywords:
-------------------------------------+---------------------

Comment (by code@…):

 I found the source of the issue, its
 [https://github.com/boostorg/spirit/blob/master/include/boost/spirit/home/karma/numeric/real_policies.hpp#L263
 this line] here. The call to `log10` rounds up to `15` instead of
 `14.9999...`.

 Fixing the issue is tricky, at least for me since I don't know many
 floating point tricks. The ideas I have:
 - Divide by 10 in a loop to simulate what the `int_inserter` is doing
 below
 - Have `int_inserter` write to a temporary stack buffer first (with output
 tracking), and then copy the stack buffer to the real one.
   - The stack buffer would be checked, and would error if it exceeded its
 bounds
 - Remove the `+ 1`
 [https://github.com/boostorg/spirit/blob/master/include/boost/spirit/home/karma/numeric/detail/real_utils.hpp#L91
 from this line].
   - Since the value no longer exceeds `digits10`, the `log10` function no
 longer rounds.
   - Doesn't seem portable or reliable, but I could be mistaken.

 Unfortunately I don't know of a way to reliably fix this without a
 performance impact. I can fix + add tests for this after some guidance.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/9405#comment:2>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:18 UTC