We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f0933b4 commit 99773d8Copy full SHA for 99773d8
include/boost/math/tools/roots.hpp
@@ -354,7 +354,12 @@ namespace detail {
354
BOOST_MATH_INSTRUMENT_VARIABLE(denom);
355
BOOST_MATH_INSTRUMENT_VARIABLE(num);
356
357
- if ((fabs(num) < 1) && (fabs(denom) >= fabs(num) * tools::max_value<T>()))
+ // denom/num overflows if:
358
+ // |denom| >= |num| * max_value
359
+ // RHS may overflow on Apple M1, so rearrange:
360
+ // |denom| * 1/max_value >= |num|
361
+ constexpr T inv_max_value = 1.0 / tools::max_value<T>();
362
+ if ((fabs(num) < 1) && (inv_max_value * fabs(denom) >= fabs(num)))
363
{
364
// possible overflow, use Newton step:
365
delta = f0 / f1;
0 commit comments