Boost C++ Libraries: Ticket #11178: cpp_dec_float calculation bug https://svn.boost.org/trac10/ticket/11178 <p> #include &lt;iostream&gt; </p> <p> #include &lt;boost/multiprecision/cpp_dec_float.hpp&gt; </p> <p> using namespace boost::multiprecision; using namespace std; </p> <p> int main(int argc, char *argv[]) { </p> <blockquote> <p> cpp_dec_float_100 p("4.5"); cpp_dec_float_100 a("7.2"); </p> </blockquote> <blockquote> <p> cpp_dec_float_100 r = p / a;<em>("0.625"); cout &lt;&lt; r.str() &lt;&lt; endl; </em></p> </blockquote> <blockquote> <p> if (r == cpp_dec_float_100("0.625")) cout &lt;&lt; "HOHO" &lt;&lt; endl; cout &lt;&lt; r.str(2, ios_base::fixed) &lt;&lt; endl; </p> </blockquote> <blockquote> <p> r *= 100; cout &lt;&lt; r.str(2, ios_base::fixed) &lt;&lt; endl; r = round(r); cout &lt;&lt; r.str(2, ios_base::fixed) &lt;&lt; endl; r /= 100; </p> </blockquote> <blockquote> <p> cout &lt;&lt; r.str(2, ios_base::fixed) &lt;&lt; endl; </p> </blockquote> <blockquote> <p> return 0; </p> </blockquote> <p> } </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11178 Trac 1.4.3 John Maddock Thu, 09 Apr 2015 17:24:41 GMT cc set https://svn.boost.org/trac10/ticket/11178#comment:1 https://svn.boost.org/trac10/ticket/11178#comment:1 <ul> <li><strong>cc</strong> <span class="trac-author">e_float@…</span> added </li> </ul> <p> I'm CC'ing Chris into this as he would know more, but I suspect this is expected behaviour as the type does not perform rounding on arithmetic operations, consequently the division produces an inexact result where an exact one should be possible. Chris? </p> Ticket