#include #include #include #include #include typedef boost::multiprecision::number > boost_float128_t; // static bool mine_is_better(const extfloat128_t a[2], const extfloat128_t& ra) // { // if (a[0]==0 && a[1] < 0 && a[0].m_sign != 0 && ra==-1) // return true; // patch, boost returns +1, my answer is -1. Mine is better // if (isnan(a[1]) && isnan(ra)) // return true; // patch, boost returns 0, my answer is nan. Mine is better // if (a[0]==0 && a[1]==0 && isnan(ra)) // return true; // patch, boost returns 0, my answer is nan. Mine is better // return false; // } int main(int , char** ) { double tests[][2] = { { HUGE_VAL, HUGE_VAL}, { -HUGE_VAL, HUGE_VAL}, { HUGE_VAL,-HUGE_VAL}, { -HUGE_VAL,-HUGE_VAL}, { -0.0, -1.0 }, { 0.0, nan("")}, { HUGE_VAL, nan("")}, { -HUGE_VAL, nan("")}, }; for (int i = 0; i < 8; ++i) { double y = tests[i][0]; double x = tests[i][1]; double r = atan2(y, x); boost_float128_t by = y; boost_float128_t bx = x; boost_float128_t br = atan2(by, bx); std::cout << "C RTL atan2(" << y << "," << x << ") = " << r << "\n"; std::cout << "Boost atan2(" << by << "," << bx << ") = " << br << "\n"; } return 0; }