2 /* @(#)z_logarithmf.c 1.0 98/08/13 */
3 /******************************************************************
4 * The following routines are coded directly from the algorithms
5 * and coefficients given in "Software Manual for the Elementary
6 * Functions" by William J. Cody, Jr. and William Waite, Prentice
8 ******************************************************************/
9 /******************************************************************
13 * x - floating point value
14 * ten - indicates base ten numbers
20 * This routine calculates logarithms.
22 *****************************************************************/
27 static const float a
[] = { -0.5527074855 };
28 static const float b
[] = { -0.6632718214e+1 };
29 static const float C1
= 0.693145752;
30 static const float C2
= 1.428606820e-06;
31 static const float C3
= 0.4342944819;
40 /* Check for domain/range errors here. */
44 return (-z_infinity_f
.f
);
49 return (z_notanum_f
.f
);
51 else if (!isfinite(x
))
54 return (z_notanum_f
.f
);
56 return (z_infinity_f
.f
);
59 /* Get the exponent and mantissa where x = f * 2^N. */
65 z
= (z
- 0.5) / (f
* 0.5 + 0.5);
73 /* Use Newton's method with 4 terms. */
74 z
+= z
* w
* (a
[0]) / ((w
+ 1.0) * w
+ b
[0]);
77 z
= (N
* C2
+ z
) + N
* C1
;