Changeset View
Changeset View
Standalone View
Standalone View
lib/msun/ld128/s_logl.c
Show First 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | |||||
* in beginning with the Taylor coefficients 0 + 1*d, which tends to happen | * in beginning with the Taylor coefficients 0 + 1*d, which tends to happen | ||||
* naturally. The most accurate minimax polynomial of a given degree might | * naturally. The most accurate minimax polynomial of a given degree might | ||||
* be different, but then we wouldn't want it since we would have to do | * be different, but then we wouldn't want it since we would have to do | ||||
* extra work to avoid roundoff error (especially for P0*d instead of d). | * extra work to avoid roundoff error (especially for P0*d instead of d). | ||||
*/ | */ | ||||
#ifdef DEBUG | #ifdef DEBUG | ||||
#include <assert.h> | #include <assert.h> | ||||
#include <fenv.h> | |||||
#endif | #endif | ||||
#include <fenv.h> | |||||
#include "fpmath.h" | #include "fpmath.h" | ||||
#include "math.h" | #include "math.h" | ||||
#ifndef NO_STRUCT_RETURN | #ifndef NO_STRUCT_RETURN | ||||
#define STRUCT_RETURN | #define STRUCT_RETURN | ||||
#endif | #endif | ||||
#include "math_private.h" | #include "math_private.h" | ||||
▲ Show 20 Lines • Show All 373 Lines • ▼ Show 20 Lines | #endif | ||||
k = -16383; | k = -16383; | ||||
#if 0 /* Hard to do efficiently. Don't do it until we support all modes. */ | #if 0 /* Hard to do efficiently. Don't do it until we support all modes. */ | ||||
if (x == 1) | if (x == 1) | ||||
RETURN1(rp, 0); /* log(1) = +0 in all rounding modes */ | RETURN1(rp, 0); /* log(1) = +0 in all rounding modes */ | ||||
#endif | #endif | ||||
if (hx == 0 || hx >= 0x8000) { /* zero, negative or subnormal? */ | if (hx == 0 || hx >= 0x8000) { /* zero, negative or subnormal? */ | ||||
if (((hx & 0x7fff) | lx | llx) == 0) | if (((hx & 0x7fff) | lx | llx) == 0) | ||||
RETURN1(rp, -1 / zero); /* log(+-0) = -Inf */ | RETURN1(rp, -1 / zero); /* log(+-0) = -Inf */ | ||||
if (hx != 0) | if (hx != 0) { | ||||
/* log(neg or NaN) = qNaN: */ | /* log(neg or NaN) = qNaN: */ | ||||
RETURN1(rp, (x - x) / zero); | if (!isnan(x)) | ||||
feraiseexcept(FE_INVALID); | |||||
RETURN1(rp, __builtin_nanl("")); | |||||
} | |||||
x *= 0x1.0p113; /* subnormal; scale up x */ | x *= 0x1.0p113; /* subnormal; scale up x */ | ||||
EXTRACT_LDBL128_WORDS(hx, lx, llx, x); | EXTRACT_LDBL128_WORDS(hx, lx, llx, x); | ||||
k = -16383 - 113; | k = -16383 - 113; | ||||
} else if (hx >= 0x7fff) | } else if (hx >= 0x7fff) | ||||
RETURN1(rp, x + x); /* log(Inf or NaN) = Inf or qNaN */ | RETURN1(rp, x + x); /* log(Inf or NaN) = Inf or qNaN */ | ||||
#ifndef STRUCT_RETURN | #ifndef STRUCT_RETURN | ||||
ENTERI(); | ENTERI(); | ||||
#endif | #endif | ||||
▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | log1pl(long double x) | ||||
DOPRINT_START(&x); | DOPRINT_START(&x); | ||||
EXTRACT_LDBL128_WORDS(hx, lx, llx, x); | EXTRACT_LDBL128_WORDS(hx, lx, llx, x); | ||||
if (hx < 0x3fff) { /* x < 1, or x neg NaN */ | if (hx < 0x3fff) { /* x < 1, or x neg NaN */ | ||||
ax = hx & 0x7fff; | ax = hx & 0x7fff; | ||||
if (ax >= 0x3fff) { /* x <= -1, or x neg NaN */ | if (ax >= 0x3fff) { /* x <= -1, or x neg NaN */ | ||||
if (ax == 0x3fff && (lx | llx) == 0) | if (ax == 0x3fff && (lx | llx) == 0) | ||||
RETURNP(-1 / zero); /* log1p(-1) = -Inf */ | RETURNP(-1 / zero); /* log1p(-1) = -Inf */ | ||||
/* log1p(x < 1, or x NaN) = qNaN: */ | /* log1p(x < 1, or x NaN) = qNaN: */ | ||||
RETURNP((x - x) / (x - x)); | if (!isnan(x)) | ||||
feraiseexcept(FE_INVALID); | |||||
RETURNP(__builtin_nanl("")); | |||||
} | } | ||||
if (ax <= 0x3f8d) { /* |x| < 2**-113 */ | if (ax <= 0x3f8d) { /* |x| < 2**-113 */ | ||||
if ((int)x == 0) | if ((int)x == 0) | ||||
RETURNP(x); /* x with inexact if x != 0 */ | RETURNP(x); /* x with inexact if x != 0 */ | ||||
} | } | ||||
f_hi = 1; | f_hi = 1; | ||||
f_lo = x; | f_lo = x; | ||||
} else if (hx >= 0x7fff) { /* x +Inf or non-neg NaN */ | } else if (hx >= 0x7fff) { /* x +Inf or non-neg NaN */ | ||||
▲ Show 20 Lines • Show All 148 Lines • Show Last 20 Lines |