[Boost-bugs] [Boost C++ Libraries] #12039: cpp_bin_float convert_to<double>() rounding mistake

Subject: [Boost-bugs] [Boost C++ Libraries] #12039: cpp_bin_float convert_to<double>() rounding mistake
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-03-02 15:32:37

#12039: cpp_bin_float convert_to<double>() rounding mistake
 Reporter: Michael Shatz <shatz@…> | Type: Bugs
   Status: new | Milestone: To Be Determined
Component: None | Version: Boost 1.61.0
 Severity: Problem | Keywords:
 There are cases where cpp_bin_float convert_to<double>() does not produce
 the nearest 'double' result. It happens when the source argument differs
 form the middle point between two double-precision values in 65th bit or
 I didn't look at boost source code, but pretty sure that the mistakes
 occurs due to double rounding. I.e. instead of direct rounding to 53-bit
 precision of 'double' the number is initially converted to 64-bit 'long
 double' and then converted from 'long double' to 'double'.

 In particular, on Microsoft compilers 'long double' and 'double' refer to
 the same type and the mistake does not happen.
 But on the same machine/OS with gcc compiler the mistake does happen.

 Below attached a simple test case that prints 'good' on platforms without
 bug and prints bad on platforms with bug.

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