2
/* exponential function check routine */
3
/* by Stephen L. Moshier. */
10
extern short maxposint[], maxnegint[];
14
unsigned short *x, *y;
16
unsigned short num[NE], den[NE], x2[NE];
18
unsigned short sign, expchk;
20
/* range reduction theory: x = i + f, 0<=f<1;
22
* e**i = 2**(i/log 2).
23
* Let i/log2 = i1 + f1, 0<=f1<1.
24
* Then e**i = 2**i1 * 2**f1, so
25
* e**x = 2**i1 * e**(log 2 * f1) * e**f.
31
if( ecmp(x, ezero) == 0 )
38
sign = expchk & 0x8000;
41
/* Test for excessively large argument */
43
if( expchk > (EXONE + 15) )
51
eifrac( x2, &i, num ); /* x = i + f */
55
ltoe( &i, den ); /* floating point i */
56
ediv( elog2, den, den ); /* i/log 2 */
57
eifrac( den, &i, den ); /* i/log 2 = i1 + f1 */
58
emul( elog2, den, den ); /* log 2 * f1 */
59
eadd( den, num, x2 ); /* log 2 * f1 + f */
63
eldexp( x2, -1L, x2 ); /* divide by 2 */
64
etanh( x2, x2 ); /* tanh( x/2 ) */
65
eadd( x2, eone, num ); /* 1 + tanh */
67
eadd( x2, eone, den ); /* 1 - tanh */
68
ediv( den, num, y ); /* (1 + tanh)/(1 - tanh) */
76
eldexp( y, i, y ); /* multiply by 2**i */