diff --git a/include/boost/math/special_functions/erf.hpp b/include/boost/math/special_functions/erf.hpp index 1f1071fc4d..69c6bd22d0 100644 --- a/include/boost/math/special_functions/erf.hpp +++ b/include/boost/math/special_functions/erf.hpp @@ -260,7 +260,7 @@ T erf_imp(T z, bool invert, const Policy& pol, const std::integral_constant +#include +#include + +#include + +BOOST_AUTO_TEST_CASE(limits_53_digits) +{ + double arg = 5.93f; + + double t = (double)boost::math::erf(boost::multiprecision::cpp_bin_float_50(arg)); + BOOST_CHECK_EQUAL(t, 1.0); + + arg = 5.9; + BOOST_CHECK_LT(boost::math::erf(arg), 1.0); + + arg = 28; + t = (double)boost::math::erfc(boost::multiprecision::cpp_bin_float_50(arg)); + BOOST_CHECK_EQUAL(t, 0.0); + + arg = 27.2; + + BOOST_CHECK_GT(boost::math::erfc(arg), 0.0); +} + +BOOST_AUTO_TEST_CASE(limits_64_digits) +{ + float arg = 6.6f; + + boost::multiprecision::cpp_bin_float_double_extended t = (boost::multiprecision::cpp_bin_float_double_extended)boost::math::erf(boost::multiprecision::cpp_bin_float_50(arg)); + BOOST_CHECK_EQUAL(t, 1.0); + +#if (LDBL_MANT_DIG == 64) && !defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS) + arg = 6.5; + BOOST_CHECK_LT(boost::math::erf(static_cast(arg)), 1.0L); +#endif + arg = 110; + t = (boost::multiprecision::cpp_bin_float_double_extended)boost::math::erfc(boost::multiprecision::cpp_bin_float_50(arg)); + BOOST_CHECK_EQUAL(t, 0.0); + +#if (LDBL_MANT_DIG == 64) && !defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS) + arg = 106.5; + BOOST_CHECK_GT(boost::math::erfc(static_cast(arg)), 0.0L); +#endif +} + +BOOST_AUTO_TEST_CASE(limits_113_digits) +{ + // + // This limit is not actually used in the code, logged here for future reference... + // + float arg = 8.8f; + + boost::multiprecision::cpp_bin_float_quad t = (boost::multiprecision::cpp_bin_float_quad)boost::math::erf(boost::multiprecision::cpp_bin_float_50(arg)); + BOOST_CHECK_EQUAL(t, 1.0); + + arg = 110; + t = (boost::multiprecision::cpp_bin_float_quad)boost::math::erfc(boost::multiprecision::cpp_bin_float_50(arg)); + BOOST_CHECK_EQUAL(t, 0.0); +}