about summary refs log tree commit diff
path: root/math/w_exp2.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2012-03-21 12:17:26 +0000
committerJoseph Myers <joseph@codesourcery.com>2012-03-21 12:17:26 +0000
commit0cb7efc517a293417880f02e2991483b7ce1e3f9 (patch)
tree6c0c2e224abce394aa9713bf8de43d4ff8012bdb /math/w_exp2.c
parent2460d3aa21f04cdf28497683bd3e29183189f779 (diff)
downloadglibc-0cb7efc517a293417880f02e2991483b7ce1e3f9.tar.gz
glibc-0cb7efc517a293417880f02e2991483b7ce1e3f9.tar.xz
glibc-0cb7efc517a293417880f02e2991483b7ce1e3f9.zip
Fix missing exp2 overflow exception (bug 13871).
Diffstat (limited to 'math/w_exp2.c')
-rw-r--r--math/w_exp2.c14
1 files changed, 5 insertions, 9 deletions
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 <float.h>
 #include <math.h>
 #include <math_private.h>
 
-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