summaryrefslogtreecommitdiff
path: root/boost/multiprecision/detail/functions/pow.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/multiprecision/detail/functions/pow.hpp')
-rw-r--r--boost/multiprecision/detail/functions/pow.hpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/boost/multiprecision/detail/functions/pow.hpp b/boost/multiprecision/detail/functions/pow.hpp
index 460658e034..179e37f400 100644
--- a/boost/multiprecision/detail/functions/pow.hpp
+++ b/boost/multiprecision/detail/functions/pow.hpp
@@ -303,6 +303,16 @@ void eval_exp(T& result, const T& x)
exp_type n;
eval_convert_to(&n, result);
+ if (n == (std::numeric_limits<exp_type>::max)())
+ {
+ // Exponent is too large to fit in our exponent type:
+ if (isneg)
+ result = ui_type(0);
+ else
+ result = std::numeric_limits<number<T> >::has_infinity ? std::numeric_limits<number<T> >::infinity().backend() : (std::numeric_limits<number<T> >::max)().backend();
+ return;
+ }
+
// The scaling is 2^11 = 2048.
const si_type p2 = static_cast<si_type>(si_type(1) << 11);