diff --git a/test/array_cwise.cpp b/test/array_cwise.cpp index 5b1c08fea..1d4f7b505 100644 --- a/test/array_cwise.cpp +++ b/test/array_cwise.cpp @@ -136,8 +136,11 @@ Scalar calc_overflow_threshold(const ScalarExponent exponent) { return NumTraits::highest(); else { // base^e <= highest ==> base <= 2^(log2(highest)/e) + // For floating-point types, consider the bound for integer values that can be reproduced exactly = 2 ^ digits + double highest_bits = numext::mini(static_cast(NumTraits::digits()), + log2(NumTraits::highest())); return static_cast( - numext::floor(exp2(log2(NumTraits::highest()) / static_cast(exponent)))); + numext::floor(exp2(highest_bits / static_cast(exponent)))); } }