|
|
1.1 root 1: /*
2: * libm/two.c
3: * Evaluate 2 to the power x.
4: * (Hart 1067, 18.08)
5: */
6:
7: #include <math.h>
8:
9: #if EMU87
10: #include "emumath.h"
11: #endif
12:
13: static readonly double twontab[] ={
14: 0.1513906799054338915894328e+04,
15: 0.2020206565128692722788600e+02,
16: 0.2309334775375023362400000e-01
17: };
18: static readonly double twomtab[] ={
19: 0.4368211662727558498496814e+04,
20: 0.2331842114274816237902950e+03,
21: 0.1000000000000000000000000e+01
22: };
23:
24: double
25: _two(x) double x;
26: {
27: double p, q, r, e;
28: register int s;
29:
30: if (x > L2HUGE_VAL) {
31: errno = ERANGE;
32: return HUGE_VAL;
33: }
34: s = 0;
35: if ((x = modf(x, &e)) < 0.0) {
36: x += 1.0;
37: e -= 1.0;
38: }
39: if (x > 0.5) {
40: s = 1;
41: x -= 0.5;
42: }
43: r = x*x;
44: p = x*_pol(r, twontab, 3);
45: q = _pol(r, twomtab, 3);
46: r = (q+p)/(q-p);
47: if (s)
48: r *= SQRT2;
49: return ldexp(r, (int) e);
50: }
51:
52: /* end of libm/two.c */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.