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 two25 = 3.3554432000e+07, /* 0x4c000000 */
21 ivln10hi = 4.3432617188e-01, /* 0x3ede6000 */
22 ivln10lo = -3.1689971365e-05, /* 0xb804ead9 */
23 log10_2hi = 3.0102920532e-01, /* 0x3e9a2080 */
24 log10_2lo = 7.9034151668e-07; /* 0x355427db */
28 float f,hfsq,hi,lo,r,y;
31 GET_FLOAT_WORD(hx, x);
34 if (hx < 0x00800000) { /* x < 2**-126 */
35 if ((hx&0x7fffffff) == 0)
36 return -two25/0.0f; /* log(+-0)=-inf */
38 return (x-x)/0.0f; /* log(-#) = NaN */
39 /* subnormal number, scale up x */
42 GET_FLOAT_WORD(hx, x);
47 return 0.0f; /* log(1) = +0 */
50 i = (hx+(0x4afb0d))&0x800000;
51 SET_FLOAT_WORD(x, hx|(i^0x3f800000)); /* normalize x or x/2 */
59 // /* See log2f.c and log2.c for details. */
60 // if (sizeof(float_t) > sizeof(float))
61 // return (r - hfsq + f) * ((float_t)ivln10lo + ivln10hi) +
62 // y * ((float_t)log10_2lo + log10_2hi);
64 GET_FLOAT_WORD(hx, hi);
65 SET_FLOAT_WORD(hi, hx&0xfffff000);
66 lo = (f - hi) - hfsq + r;
67 return y*log10_2lo + (lo+hi)*ivln10lo + lo*ivln10hi +
68 hi*ivln10hi + y*log10_2hi;