Skip to content

Commit

Permalink
FIX: avoid overflow on overflow check in toms748_solve safe_div on A…
Browse files Browse the repository at this point in the history
…pple M1
  • Loading branch information
mckib2 committed Feb 4, 2023
1 parent f0933b4 commit 3cf46ad
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/boost/math/tools/toms748_solve.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ inline T safe_div(T num, T denom, T r)

if(fabs(denom) < 1)
{
if(fabs(denom * tools::max_value<T>()) <= fabs(num))
constexpr T inv_max_value = 1.0 / tools::max_value<T>();
if(fabs(denom) <= inv_max_value * fabs(num))
return r;
}
return num / denom;
Expand Down

0 comments on commit 3cf46ad

Please sign in to comment.