Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
FIX: avoid overflow on overflow check in gamma_p_derivative_imp
  • Loading branch information
mckib2 committed Feb 5, 2023
commit 6b580bd6f18d485b9656d6918cfbca1e929c123e
3 changes: 2 additions & 1 deletion include/boost/math/special_functions/gamma.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1795,7 +1795,8 @@ T gamma_p_derivative_imp(T a, T x, const Policy& pol)
//
typedef typename lanczos::lanczos<T, Policy>::type lanczos_type;
T f1 = detail::regularised_gamma_prefix(a, x, pol, lanczos_type());
if((x < 1) && (tools::max_value<T>() * x < f1))
static const T inv_max_value = 1.0 / tools::max_value<T>();
if((x < 1) && (x < inv_max_value * f1))
{
// overflow:
return policies::raise_overflow_error<T>("boost::math::gamma_p_derivative<%1%>(%1%, %1%)", nullptr, pol);
Expand Down