From 0cb7efc517a293417880f02e2991483b7ce1e3f9 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Wed, 21 Mar 2012 12:17:26 +0000 Subject: Fix missing exp2 overflow exception (bug 13871). --- math/w_exp2.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'math/w_exp2.c') diff --git a/math/w_exp2.c b/math/w_exp2.c index 7a3b0afb74..b5d8e25702 100644 --- a/math/w_exp2.c +++ b/math/w_exp2.c @@ -2,23 +2,19 @@ * wrapper exp2(x) */ -#include #include #include -static const double o_threshold = (double) DBL_MAX_EXP; -static const double u_threshold = (double) (DBL_MIN_EXP - DBL_MANT_DIG - 1); - double __exp2 (double x) { - if (__builtin_expect (islessequal (x, u_threshold) - || isgreater (x, o_threshold), 0) - && _LIB_VERSION != _IEEE_ && __finite (x)) + double z = __ieee754_exp2 (x); + if (__builtin_expect (!__finite (z), 0) + && __finite (x) && _LIB_VERSION != _IEEE_) /* exp2 overflow: 44, exp2 underflow: 45 */ - return __kernel_standard (x, x, 44 + (x <= o_threshold)); + return __kernel_standard (x, x, 44 + !!__signbit (x)); - return __ieee754_exp2 (x); + return z; } weak_alias (__exp2, exp2) #ifdef NO_LONG_DOUBLE -- cgit v1.2.3