id summary reporter owner description type status milestone component version severity resolution keywords cc 12327 cpp_rational::convert_to() does not return the nearest number komakisen@… John Maddock "Hello, I tested with the following program to see if boost::multiprecision::cpp_rational::convert_to() returns the nearest double number to the exact value. I expected it to print only ""true""s, but it actually prints some ""false""s too. Is it a bug or (un)documented behavior? {{{#!c++ #include typedef boost::multiprecision::cpp_rational NT; void test_convert_to_double(double d1, double d2) { NT r1(d1); NT r2(d2); NT two(2); NT three(3); NT r112 = (two * r1 + r2) / three; NT r12 = (r1 + r2) / two; NT r122 = (r1 + two * r2) / three; double rd1 = r1.convert_to(); double rd112 = r112.convert_to(); double rd12 = r12.convert_to(); double rd122 = r122.convert_to(); double rd2 = r2.convert_to(); std::cout << std::boolalpha; std::cout << (rd1 == d1) << std::endl; std::cout << (rd112 == d1) << std::endl; std::cout << (rd12 == d2) << std::endl; std::cout << (rd122 == d2) << std::endl; std::cout << (rd2 == d2) << std::endl; } int main() { volatile double a = 0.099999999999999992; volatile double b = 0.10000000000000001; volatile double c = 0.10000000000000002; // prints true, false, true, true, true test_convert_to_double(a, b); // prints true, true, false, false, true test_convert_to_double(b, c); return 0; } }}} I compiled this program with MSVC 14.0 and ICL 16.0.3, both for x64 Debug build. They give the same results. " Bugs closed Boost 1.62.0 multiprecision Boost 1.61.0 Problem fixed komakisen@…