1 # exp(x) = 2^hi + 2^hi (2^lo - 1)
2 # where hi+lo = log2e*x with 128bit precision
3 # exact log2e*x calculation depends on nearest rounding mode
4 # using the exact multiplication method of Dekker and Veltkamp
11 # special cases: 2*x is +-inf, nan or |x| < 0x1p-32
12 # check (exponent|0x8000)+2 < 0xbfff+2-32
21 # if |x|<0x1p-32 return 1+x
26 # if 2*x == -inf,-nan return -0/x
31 # if 2*x == inf,nan return 2*x
36 # should be 0x1.71547652b82fe178p0 == 0x3fff b8aa3b29 5c17f0bc
37 # it will be wrong on non-nearest rounding mode
48 # if 2^hi == inf return 2^hi
55 # fpu stack: 2^hi x hi
70 # yh = log2e_hi - c*log2e_hi + c*log2e_hi
74 # fpu stack: 2^hi x hi xh xl yh
75 # lo = hi - xh*yh + xl*yh
85 # fpu stack: 2^hi x lo xh xl yl
98 # fpu stack: 2^hi x lo log2e_lo
100 # return 2^hi + 2^hi (2^lo - 1)