X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fmath%2Fexpm1l.c;h=21a86c00518783a9f994eaf13aa119214bb2387a;hb=3bb6bd85808ace7b588d1c523bb7badfd9e72650;hp=2f94dfa20071dd115c1d699f7fed1c7dfffa16f3;hpb=b69f695acedd4ce2798ef9ea28d834ceccc789bd;p=musl diff --git a/src/math/expm1l.c b/src/math/expm1l.c index 2f94dfa2..21a86c00 100644 --- a/src/math/expm1l.c +++ b/src/math/expm1l.c @@ -44,13 +44,7 @@ * * Relative error: * arithmetic domain # trials peak rms - * IEEE -45,+MAXLOG 200,000 1.2e-19 2.5e-20 - * - * ERROR MESSAGES: - * - * message condition value returned - * expm1l overflow x > MAXLOG MAXNUM - * + * IEEE -45,+maxarg 200,000 1.2e-19 2.5e-20 */ #include "libm.h" @@ -61,7 +55,6 @@ long double expm1l(long double x) return expm1(x); } #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 -static const long double MAXLOGL = 1.1356523406294143949492E4L; /* exp(x) - 1 = x + 0.5 x^2 + x^3 P(x)/Q(x) -.5 ln 2 < x < .5 ln 2 @@ -83,25 +76,26 @@ C1 = 6.93145751953125E-1L, C2 = 1.428606820309417232121458176568075500134E-6L, /* ln 2^-65 */ minarg = -4.5054566736396445112120088E1L, -huge = 0x1p10000L; +/* ln 2^16384 */ +maxarg = 1.1356523406294143949492E4L; long double expm1l(long double x) { long double px, qx, xx; int k; - /* Overflow. */ - if (x > MAXLOGL) - return huge*huge; /* overflow */ + if (isnan(x)) + return x; + if (x > maxarg) + return x*0x1p16383L; /* overflow, unless x==inf */ if (x == 0.0) return x; - /* Minimum value.*/ if (x < minarg) - return -1.0L; + return -1.0; xx = C1 + C2; /* Express x = ln 2 (k + remainder), remainder not exceeding 1/2. */ - px = floorl (0.5 + x / xx); + px = floorl(0.5 + x / xx); k = px; /* remainder times ln 2 */ x -= px * C1; @@ -116,7 +110,7 @@ long double expm1l(long double x) /* exp(x) = exp(k ln 2) exp(remainder ln 2) = 2^k exp(remainder ln 2). We have qx = exp(remainder ln 2) - 1, so exp(x) - 1 = 2^k (qx + 1) - 1 = 2^k qx + 2^k - 1. */ - px = ldexpl(1.0L, k); + px = scalbnl(1.0, k); x = px * qx + (px - 1.0); return x; }