Re: [Boost-bugs] [Boost C++ Libraries] #10639: lexical_cast<double>(string) wrong in C++11

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #10639: lexical_cast<double>(string) wrong in C++11
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-10-11 09:40:47


#10639: lexical_cast<double>(string) wrong in C++11
--------------------------------+--------------------------
  Reporter: richard.kreckel@… | Owner: apolukhin
      Type: Bugs | Status: assigned
 Milestone: To Be Determined | Component: lexical_cast
   Version: Boost 1.56.0 | Severity: Problem
Resolution: | Keywords:
--------------------------------+--------------------------
Changes (by apolukhin):

 * status: new => assigned

Comment:

 The problem seems to be much worse than it looks like.

 CLANG-3.4 and GCC-4.8.2 produce same results in C++03 and C++11 mode.
 Moreover, code in LexicalCast that does the conversion '''must work
 exactly the same way''' in C++11 and C++03. It is pretty simple and does
 not use real number types until the very end:

 {{{
     const wide_result_t result =
 std::pow(static_cast<wide_result_t>(10.0), pow_of_10) * mantissa;
     value = static_cast<T>( has_minus ? (boost::math::changesign)(result)
 : result);
 }}}

 This makes me think that there's probably some precision error in
 `std::pow`.

 Unfortunately I have no access to GCC-4.9 and Clang-3.5 at this moment, so
 I can not investigate this issue further. Please, could someone do it?


 Thanks for the [http://www.exploringbinary.com/real-c-rounding-is-perfect-
 gcc-now-converts-correctly/ link]! I'll put the test cases from it to the
 lexical cast auto tests and in case of errors will fallback to something
 like std::num_get. Maybe even with tests passing fallback to num_get will
 be done: current algo heavily relies on hardware precision and does not
 work in some cases (issue #6975).

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/10639#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:17 UTC