]> git.ipfire.org Git - thirdparty/glibc.git/blob - math/w_exp2.c
Use non-signaling floating-point comparisons in math functions.
[thirdparty/glibc.git] / math / w_exp2.c
1 /*
2 * wrapper exp2(x)
3 */
4
5 #include <float.h>
6 #include <math.h>
7 #include <math_private.h>
8
9 static const double o_threshold = (double) DBL_MAX_EXP;
10 static const double u_threshold = (double) (DBL_MIN_EXP - DBL_MANT_DIG - 1);
11
12 double
13 __exp2 (double x)
14 {
15 if (__builtin_expect (islessequal (x, u_threshold)
16 || isgreater (x, o_threshold), 0)
17 && _LIB_VERSION != _IEEE_ && __finite (x))
18 /* exp2 overflow: 44, exp2 underflow: 45 */
19 return __kernel_standard (x, x, 44 + (x <= o_threshold));
20
21 return __ieee754_exp2 (x);
22 }
23 weak_alias (__exp2, exp2)
24 #ifdef NO_LONG_DOUBLE
25 strong_alias (__exp2, __exp2l)
26 weak_alias (__exp2, exp2l)
27 #endif