Print this page
11210 libm should be cstyle(1ONBLD) clean
*** 16,36 ****
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma weak __log10 = log10
! /* INDENT OFF */
/*
* log10(x) = log(x)/log10
*
* Base on Table look-up algorithm with product polynomial
* approximation for log(x).
--- 16,38 ----
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
+
/*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
*/
+
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma weak __log10 = log10
!
/*
* log10(x) = log(x)/log10
*
* Base on Table look-up algorithm with product polynomial
* approximation for log(x).
*** 83,100 ****
* The hexadecimal values are the intended ones for the following constants.
* The decimal values may be used, provided that the compiler will convert
* from decimal to binary accurately enough to produce the hexadecimal values
* shown.
*/
- /* INDENT ON */
#include "libm.h"
extern const double _TBL_log[];
static const double P[] = {
! /* ONE */ 1.0,
/* TWO52 */ 4503599627370496.0,
/* LNAHI */ 3.01029995607677847147e-01, /* 3FD34413 50900000 */
/* LNALO */ 5.63033480667509769841e-11, /* 3DCEF3FD E623E256 */
/* A1 */ -2.9142521960136582507385480707044582802184e-02,
/* A2 */ 1.99628461483039965074226529395673424005508422852e+0000,
--- 85,102 ----
* The hexadecimal values are the intended ones for the following constants.
* The decimal values may be used, provided that the compiler will convert
* from decimal to binary accurately enough to produce the hexadecimal values
* shown.
*/
#include "libm.h"
extern const double _TBL_log[];
static const double P[] = {
! /* ONE */
! 1.0,
/* TWO52 */ 4503599627370496.0,
/* LNAHI */ 3.01029995607677847147e-01, /* 3FD34413 50900000 */
/* LNALO */ 5.63033480667509769841e-11, /* 3DCEF3FD E623E256 */
/* A1 */ -2.9142521960136582507385480707044582802184e-02,
/* A2 */ 1.99628461483039965074226529395673424005508422852e+0000,
*** 148,158 ****
#define LGH P[24]
#define LGL P[25]
#define LG10V P[26]
double
! log10(double x) {
double *tb, dn, dn1, s, z, r, w;
int i, hx, ix, n, lx;
n = 0;
hx = ((int *)&x)[HIWORD];
--- 150,161 ----
#define LGH P[24]
#define LGL P[25]
#define LG10V P[26]
double
! log10(double x)
! {
double *tb, dn, dn1, s, z, r, w;
int i, hx, ix, n, lx;
n = 0;
hx = ((int *)&x)[HIWORD];
*** 161,174 ****
--- 164,180 ----
/* subnormal,0,negative,inf,nan */
if ((hx + 0x100000) < 0x200000) {
if (ix > 0x7ff00000 || (ix == 0x7ff00000 && lx != 0)) /* nan */
return (x * x);
+
if (((hx << 1) | lx) == 0) /* zero */
return (_SVID_libm_err(x, x, 18));
+
if (hx < 0) /* negative */
return (_SVID_libm_err(x, x, 19));
+
if (((hx - 0x7ff00000) | lx) == 0) /* +inf */
return (x);
/* x must be positive and subnormal */
x *= TWO52;
*** 176,193 ****
--- 182,202 ----
ix = ((int *)&x)[HIWORD];
lx = ((int *)&x)[LOWORD];
}
i = ix >> 19;
+
if (i >= 0x7f7 && i <= 0x806) {
/* 0.09375 (0x3fb80000) <= x < 24 (0x40380000) */
if (ix >= 0x3fec0000 && ix < 0x3ff20000) {
/* 0.875 <= x < 1.125 */
s = x - ONE;
z = s * s;
+
if (((ix - 0x3ff00000) | lx) == 0) /* x = 1 */
return (z);
+
r = (A10 * s) * (A11 + s);
w = z * s;
return (LGH * s - (LGL * s - ((A1 * z) *
((A2 + (A3 * s) * (A4 + s)) + w * (A5 + s))) *
(((A6 + s * (A7 + s)) + w * (A8 + s)) *
*** 195,218 ****
} else {
i = (ix - 0x3fb80000) >> 15;
tb = (double *)_TBL_log + (i + i + i);
s = (x - tb[0]) * tb[1];
return (LGH * tb[2] - (LGL * tb[2] - ((B1 * s) *
! (B2 + s * (B3 + s))) *
! (((B4 + s * B5) + (s * s) * (B6 + s)) *
! (B7 + s * (B8 + s)))));
}
} else {
dn = (double)(n + ((ix >> 20) - 0x3ff));
dn1 = dn * LNAHI;
i = (ix & 0x000fffff) | 0x3ff00000; /* scale x to [1,2] */
((int *)&x)[HIWORD] = i;
i = (i - 0x3fb80000) >> 15;
tb = (double *)_TBL_log + (i + i + i);
s = (x - tb[0]) * tb[1];
dn = dn * LNALO + tb[2] * LG10V;
! return (dn1 + (dn + ((B1 * s) *
! (B2 + s * (B3 + s))) *
(((B4 + s * B5) + (s * s) * (B6 + s)) *
(B7 + s * (B8 + s)))));
}
}
--- 204,225 ----
} else {
i = (ix - 0x3fb80000) >> 15;
tb = (double *)_TBL_log + (i + i + i);
s = (x - tb[0]) * tb[1];
return (LGH * tb[2] - (LGL * tb[2] - ((B1 * s) *
! (B2 + s * (B3 + s))) * (((B4 + s * B5) + (s * s) *
! (B6 + s)) * (B7 + s * (B8 + s)))));
}
} else {
dn = (double)(n + ((ix >> 20) - 0x3ff));
dn1 = dn * LNAHI;
i = (ix & 0x000fffff) | 0x3ff00000; /* scale x to [1,2] */
((int *)&x)[HIWORD] = i;
i = (i - 0x3fb80000) >> 15;
tb = (double *)_TBL_log + (i + i + i);
s = (x - tb[0]) * tb[1];
dn = dn * LNALO + tb[2] * LG10V;
! return (dn1 + (dn + ((B1 * s) * (B2 + s * (B3 + s))) *
(((B4 + s * B5) + (s * s) * (B6 + s)) *
(B7 + s * (B8 + s)))));
}
}