[Boost-bugs] [Boost C++ Libraries] #13148: Zero value cannot be converted from cpp_dec_float_50 to cpp_rational

Subject: [Boost-bugs] [Boost C++ Libraries] #13148: Zero value cannot be converted from cpp_dec_float_50 to cpp_rational
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-08-05 11:10:22


#13148: Zero value cannot be converted from cpp_dec_float_50 to cpp_rational
-----------------------------------+----------------------------
 Reporter: Lev Sch <zorechfan@…> | Owner: John Maddock
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: multiprecision
  Version: Boost 1.64.0 | Severity: Problem
 Keywords: |
-----------------------------------+----------------------------
 String "boost::multiprecision::cpp_rational result(d1);" eats CPU forever.

 It is reproduced on boost_1_65_0_beta1 and boost_1_64_0.

 {{{

 boost::multiprecision::cpp_rational rationalfromStr(const char* str)
 {
   boost::multiprecision::cpp_dec_float_50 d1(str);
   boost::multiprecision::cpp_rational result(d1); // <--- eats CPU forever
   return result;
 }

 void test()
 {
   // this example is OK
   {
     boost::multiprecision::cpp_rational expected=1;
     assert(expected == rationalfromStr("1"));
   }
   // this example is OK
   {
     boost::multiprecision::cpp_rational
 expected=boost::multiprecision::cpp_rational(25)/boost::multiprecision::cpp_rational(10);
     assert(expected == rationalfromStr("2.5"));
   }
   // this example is OK
   {
     boost::multiprecision::cpp_rational
 expected=boost::multiprecision::cpp_rational(5)/boost::multiprecision::cpp_rational(1000);
     assert(expected == rationalfromStr("0.005"));
   }
   // this example is OK
   {
     boost::multiprecision::cpp_rational expected=0;
     assert(expected == boost::multiprecision::cpp_rational("0")); //
 direct cpp_rational from str is ok
   }
   // this example fails
   {
     boost::multiprecision::cpp_rational expected=0;
     // reacheble code
     assert(expected == rationalfromStr("0")); // cpp_rational from
 cpp_dec_float_50 is not ok
     // unreacheble code
   }
 }

 }}}

-- 
Ticket URL: <https://svn.boost.org/trac10/boost/ticket/13148>
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-08-05 11:13:36 UTC