1 /* origin: FreeBSD /usr/src/lib/msun/src/e_log10f.c */
3 * ====================================================
4 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
6 * Developed at SunPro, a Sun Microsystems, Inc. business.
7 * Permission to use, copy, modify, and distribute this
8 * software is freely granted, provided that this notice
10 * ====================================================
13 * See comments in log10.c.
20 ivln10hi = 4.3432617188e-01, /* 0x3ede6000 */
21 ivln10lo = -3.1689971365e-05, /* 0xb804ead9 */
22 log10_2hi = 3.0102920532e-01, /* 0x3e9a2080 */
23 log10_2lo = 7.9034151668e-07, /* 0x355427db */
24 /* |(log(1+s)-log(1-s))/s - Lg(s)| < 2**-34.24 (~[-4.95e-11, 4.97e-11]). */
25 Lg1 = 0xaaaaaa.0p-24, /* 0.66666662693 */
26 Lg2 = 0xccce13.0p-25, /* 0.40000972152 */
27 Lg3 = 0x91e9ee.0p-25, /* 0.28498786688 */
28 Lg4 = 0xf89e26.0p-26; /* 0.24279078841 */
32 union {float f; uint32_t i;} u = {x};
33 float_t hfsq,f,s,z,R,w,t1,t2,dk,hi,lo;
39 if (ix < 0x00800000 || ix>>31) { /* x < 2**-126 */
41 return -1/(x*x); /* log(+-0)=-inf */
43 return (x-x)/0.0f; /* log(-#) = NaN */
44 /* subnormal number, scale up x */
49 } else if (ix >= 0x7f800000) {
51 } else if (ix == 0x3f800000)
54 /* reduce x into [sqrt(2)/2, sqrt(2)] */
55 ix += 0x3f800000 - 0x3f3504f3;
56 k += (int)(ix>>23) - 0x7f;
57 ix = (ix&0x007fffff) + 0x3f3504f3;
74 lo = f - hi - hfsq + s*(hfsq+R);
76 return dk*log10_2lo + (lo+hi)*ivln10lo + lo*ivln10hi + hi*ivln10hi + dk*log10_2hi;