diff --git a/include/boost/multiprecision/cpp_bin_float/transcendental.hpp b/include/boost/multiprecision/cpp_bin_float/transcendental.hpp index 9afcc4e7..9037dd39 100644 --- a/include/boost/multiprecision/cpp_bin_float/transcendental.hpp +++ b/include/boost/multiprecision/cpp_bin_float/transcendental.hpp @@ -103,7 +103,12 @@ void eval_exp(cpp_bin_float eval_multiply(t, n, default_ops::get_constant_ln2 >()); eval_subtract(t, arg); t.negate(); - BOOST_ASSERT(t.compare(limb_type(0)) >= 0); + if(eval_get_sign(t) < 0) + { + // There are some very rare cases where arg/ln2 is an integer, and the subsequent multiply + // rounds up, in that situation t ends up negative at this point which breaks our invariants below: + t = limb_type(0); + } BOOST_ASSERT(t.compare(default_ops::get_constant_ln2 >()) < 0); Exponent k, nn;