61ae7fd804a03916eb1befdafa7b756a3f4a62e9
[libm] / src / math / __expo2.c
1 #include "libm.h"
2
3 /* k minimizes |exp(k ln2) - 2**k|, see cmath/__cexp.c */
4 static const uint32_t k = 1799;
5 static const double kln2 = 1246.97177782734161156;
6
7 /* exp(x)/2 for large x */
8 double __expo2(double x)
9 {
10         double scale;
11
12         /* note that k is odd and scale*scale overflows */
13         INSERT_WORDS(scale, (0x3ff + k/2) << 20, 0);
14         /* exp(x - k ln2) * 2**(k-1) */
15         return exp(x - kln2) * scale * scale;
16 }