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 __log = log
! /* INDENT OFF */
/*
* log(x)
* Table look-up algorithm with product polynomial approximation.
* By K.C. Ng, Oct 23, 2004. Updated Oct 18, 2005.
*
--- 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 __log = log
!
/*
* log(x)
* Table look-up algorithm with product polynomial approximation.
* By K.C. Ng, Oct 23, 2004. Updated Oct 18, 2005.
*
*** 93,110 ****
* 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,
/* LN2HI */ 6.93147180369123816490e-01, /* 3fe62e42, fee00000 */
/* LN2LO */ 1.90821492927058770002e-10, /* 3dea39ef, 35793c76 */
/* A1 */ -6.88821452420390473170286327331268694251775741577e-0002,
/* A2 */ 1.97493380704769294631262255279580131173133850098e+0000,
--- 95,112 ----
* 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,
/* LN2HI */ 6.93147180369123816490e-01, /* 3fe62e42, fee00000 */
/* LN2LO */ 1.90821492927058770002e-10, /* 3dea39ef, 35793c76 */
/* A1 */ -6.88821452420390473170286327331268694251775741577e-0002,
/* A2 */ 1.97493380704769294631262255279580131173133850098e+0000,
*** 152,162 ****
#define B6 P[21]
#define B7 P[22]
#define B8 P[23]
double
! log(double x) {
double *tb, dn, dn1, s, z, r, w;
int i, hx, ix, n, lx;
n = 0;
hx = ((int *)&x)[HIWORD];
--- 154,165 ----
#define B6 P[21]
#define B7 P[22]
#define B8 P[23]
double
! log(double x)
! {
double *tb, dn, dn1, s, z, r, w;
int i, hx, ix, n, lx;
n = 0;
hx = ((int *)&x)[HIWORD];
*** 165,178 ****
--- 168,184 ----
/* 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, 16));
+
if (hx < 0) /* negative */
return (_SVID_libm_err(x, x, 17));
+
if (((hx - 0x7ff00000) | lx) == 0) /* +inf */
return (x);
/* x must be positive and subnormal */
x *= TWO52;
*** 180,203 ****
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 < 0x3ff22000) {
/* 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 (s + ((A1 * z) *
! (A2 + ((A3 * s) * (A4 + s) + w * (A5 + s)))) *
! ((A6 + (s * (A7 + s) + w * (A8 + s))) *
! (A9 + (r + w * (A12 + s)))));
} else {
i = (ix - 0x3fb80000) >> 15;
tb = (double *)_TBL_log + (i + i + i);
s = (x - tb[0]) * tb[1];
return (tb[2] + ((B1 * s) * (B2 + s * (B3 + s))) *
--- 186,211 ----
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 < 0x3ff22000) {
/* 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 (s + ((A1 * z) * (A2 + ((A3 * s) * (A4 + s) + w *
! (A5 + s)))) * ((A6 + (s * (A7 + s) + w *
! (A8 + s))) * (A9 + (r + w * (A12 + s)))));
} else {
i = (ix - 0x3fb80000) >> 15;
tb = (double *)_TBL_log + (i + i + i);
s = (x - tb[0]) * tb[1];
return (tb[2] + ((B1 * s) * (B2 + s * (B3 + s))) *