[Boost-bugs] [Boost C++ Libraries] #11178: cpp_dec_float calculation bug

Subject: [Boost-bugs] [Boost C++ Libraries] #11178: cpp_dec_float calculation bug
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-04-09 17:01:00


#11178: cpp_dec_float calculation bug
------------------------------+----------------------------
 Reporter: nxjiang1@… | Owner: johnmaddock
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: multiprecision
  Version: Boost 1.57.0 | Severity: Problem
 Keywords: |
------------------------------+----------------------------
 #include <iostream>

 #include <boost/multiprecision/cpp_dec_float.hpp>

 using namespace boost::multiprecision;
 using namespace std;

 int main(int argc, char *argv[]) {
     cpp_dec_float_100 p("4.5");
     cpp_dec_float_100 a("7.2");

     cpp_dec_float_100 r = p / a;//("0.625");
     cout << r.str() << endl;

     if (r == cpp_dec_float_100("0.625")) cout << "HOHO" << endl;
     cout << r.str(2, ios_base::fixed) << endl;

     r *= 100;
     cout << r.str(2, ios_base::fixed) << endl;
     r = round(r);
     cout << r.str(2, ios_base::fixed) << endl;
     r /= 100;

     cout << r.str(2, ios_base::fixed) << endl;

     return 0;
 }

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