[Boost-bugs] [Boost C++ Libraries] #13264: Floating point math going wrong using cpp_bin_float with 64 bit exponent

Subject: [Boost-bugs] [Boost C++ Libraries] #13264: Floating point math going wrong using cpp_bin_float with 64 bit exponent
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-10-18 20:06:33


#13264: Floating point math going wrong using cpp_bin_float with 64 bit exponent
--------------------------+----------------------------
 Reporter: private@… | Owner: John Maddock
     Type: Bugs | Status: new
Milestone: | Component: multiprecision
  Version: Boost 1.65.0 | Severity: Problem
 Keywords: |
--------------------------+----------------------------
 I tried the following:

 {{{
 #include <cmath>
 #include <iostream>
 #include <boost/multiprecision/cpp_bin_float.hpp>

 using float256 =
 boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<192,
                   boost::multiprecision::backends::digit_base_2, void,
 long long int>, boost::multiprecision::et_off>;

 void Test()
 {
    double a = exp(-0.5);
    double b =
 boost::multiprecision::exp(float256(-0.5)).convert_to<double>();
    cout << a << endl << b << endl;
 }
 }}}

 Unfortunately this doesn't work. I am getting 0.606531 for a but 1 for b.
 Using an int as exponent fixes the problem.

 I'm running: boost 1.65.1, Linux, gcc 5.4.0.

-- 
Ticket URL: <https://svn.boost.org/trac10/boost/ticket/13264>
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-10-18 20:18:36 UTC