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 */
26 static const float zero = 0.0;
30 float f,hfsq,hi,lo,r,y;
33 GET_FLOAT_WORD(hx, x);
36 if (hx < 0x00800000) { /* x < 2**-126 */
37 if ((hx&0x7fffffff) == 0)
38 return -two25/zero; /* log(+-0)=-inf */
40 return (x-x)/zero; /* log(-#) = NaN */
41 /* subnormal number, scale up x */
44 GET_FLOAT_WORD(hx, x);
49 return zero; /* log(1) = +0 */
52 i = (hx+(0x4afb0d))&0x800000;
53 SET_FLOAT_WORD(x, hx|(i^0x3f800000)); /* normalize x or x/2 */
61 // /* See log2f.c and log2.c for details. */
62 // if (sizeof(float_t) > sizeof(float))
63 // return (r - hfsq + f) * ((float_t)ivln10lo + ivln10hi) +
64 // y * ((float_t)log10_2lo + log10_2hi);
66 GET_FLOAT_WORD(hx, hi);
67 SET_FLOAT_WORD(hi, hx&0xfffff000);
68 lo = (f - hi) - hfsq + r;
69 return y*log10_2lo + (lo+hi)*ivln10lo + lo*ivln10hi +
70 hi*ivln10hi + y*log10_2hi;