diff --git a/include/boost/multiprecision/cpp_int/misc.hpp b/include/boost/multiprecision/cpp_int/misc.hpp index cdae2f757..a8a764003 100644 --- a/include/boost/multiprecision/cpp_int/misc.hpp +++ b/include/boost/multiprecision/cpp_int/misc.hpp @@ -184,7 +184,9 @@ eval_convert_to(R* result, const cpp_int_backend inline BOOST_MP_CXX14_CONSTEXPR typename std::enable_if::value && !is_trivial_cpp_int >::value, void>::type -eval_convert_to(R* result, const cpp_int_backend& backend) noexcept(boost::multiprecision::detail::is_arithmetic::value && std::numeric_limits::has_infinity) +eval_convert_to(R* result, const cpp_int_backend& backend) noexcept(boost::multiprecision::detail::is_arithmetic::value && + (std::numeric_limits::has_infinity || + std::numeric_limits::has_quiet_NaN)) { BOOST_MP_FLOAT128_USING using std::ldexp; if (eval_is_zero(backend)) @@ -244,10 +246,11 @@ eval_convert_to(R* result, const cpp_int_backend(bits)) || eval_bit_test(backend, static_cast(bits + 1))) { #ifdef BOOST_MP_MATH_AVAILABLE - BOOST_IF_CONSTEXPR(std::numeric_limits::has_infinity) + BOOST_IF_CONSTEXPR(std::numeric_limits::has_infinity || std::numeric_limits::has_quiet_NaN) { // Must NOT throw: - *result = boost::math::float_next(*result, boost::math::policies::make_policy(boost::math::policies::overflow_error())); + *result = boost::math::float_next(*result, boost::math::policies::make_policy(boost::math::policies::overflow_error(), + boost::math::policies::domain_error())); } else {