diff --git a/test/array_cwise.cpp b/test/array_cwise.cpp index 502d1cc9d..5b1c08fea 100644 --- a/test/array_cwise.cpp +++ b/test/array_cwise.cpp @@ -129,15 +129,15 @@ void pow_test() { template Scalar calc_overflow_threshold(const ScalarExponent exponent) { EIGEN_USING_STD(exp2); + EIGEN_USING_STD(log2); EIGEN_STATIC_ASSERT((NumTraits::digits() < 2 * NumTraits::digits()), BASE_TYPE_IS_TOO_BIG); if (exponent < 2) return NumTraits::highest(); else { - const double max_exponent = static_cast(NumTraits::digits()); - const double clamped_exponent = exponent < max_exponent ? static_cast(exponent) : max_exponent; - const double threshold = exp2(max_exponent / clamped_exponent); - return static_cast(threshold); + // base^e <= highest ==> base <= 2^(log2(highest)/e) + return static_cast( + numext::floor(exp2(log2(NumTraits::highest()) / static_cast(exponent)))); } }