diff --git a/include/boost/math/special_functions/gamma.hpp b/include/boost/math/special_functions/gamma.hpp index 68afe66e30..efd9eef713 100644 --- a/include/boost/math/special_functions/gamma.hpp +++ b/include/boost/math/special_functions/gamma.hpp @@ -1795,7 +1795,8 @@ T gamma_p_derivative_imp(T a, T x, const Policy& pol) // typedef typename lanczos::lanczos::type lanczos_type; T f1 = detail::regularised_gamma_prefix(a, x, pol, lanczos_type()); - if((x < 1) && (tools::max_value() * x < f1)) + static const T inv_max_value = 1.0 / tools::max_value(); + if((x < 1) && (x < inv_max_value * f1)) { // overflow: return policies::raise_overflow_error("boost::math::gamma_p_derivative<%1%>(%1%, %1%)", nullptr, pol);