2 * (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 * See the copyright notice in the ACK home directory, in the file "Copyright".
5 * Author: Ceriel J.H. Jacobs
17 #define M_MIN_D DBL_MIN
18 #define M_MAX_D DBL_MAX
19 #define M_DMINEXP DBL_MIN_EXP
37 fl
= _fef(fl
,&currexp
);
41 fl
*= (double) (1L << 30);
44 fl
*= (double) (1L << exp
);
48 fl
/= (double) (1L << 30);
51 fl
/= (double) (1L << -exp
);
60 /* Algorithm and coefficients from:
61 "Software manual for the elementary functions"
62 by W.J. Cody and W. Waite, Prentice-Hall, 1980
66 0.25000000000000000000e+0,
67 0.75753180159422776666e-2,
68 0.31555192765684646356e-4
72 0.50000000000000000000e+0,
73 0.56817302698551221787e-1,
74 0.63121894374398503557e-3,
75 0.75104028399870046114e-6
81 if (x
<= M_LN_MIN_D
) {
85 /* unnormalized numbers apparently exist */
86 if (x
< (M_LN2
* (M_DMINEXP
- 53))) return 0.0;
89 if (x
< M_LN_MIN_D
) return 0.0;
93 if (x
>= M_LN_MAX_D
) {
100 if (negative
) x
= -x
;
102 n
= x
* M_LOG2E
+ 0.5; /* 1/ln(2) = log2(e), 0.5 added for rounding */
105 double x1
= (long) x
;
108 g
= ((x1
-xn
*0.693359375)+x2
) - xn
*(-2.1219444005469058277e-4);
115 x
= g
* POLYNOM2(xn
, p
);
117 return (Ldexp(0.5 + x
/(POLYNOM3(xn
, q
) - x
), n
));