X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fmath%2Fexpf.c;h=16e9afe62a21cbd09d6845f8076fb37e4fa5a560;hb=7acbbdfd5d6e264dcf8efa13188f0c8edabee047;hp=8aefc9176c87b69d3f760c88a93ee71ac09a9733;hpb=19b1a8453e9d329a16711900a84797c5f1333208;p=musl diff --git a/src/math/expf.c b/src/math/expf.c index 8aefc917..16e9afe6 100644 --- a/src/math/expf.c +++ b/src/math/expf.c @@ -29,7 +29,7 @@ P2 = -2.7667332906e-3f; /* -0xb55215.0p-32 */ float expf(float x) { - float hi, lo, c, xx; + float_t hi, lo, c, xx, y; int k, sign; uint32_t hx; @@ -38,20 +38,17 @@ float expf(float x) hx &= 0x7fffffff; /* high word of |x| */ /* special cases */ - if (hx >= 0x42b17218) { /* if |x| >= 88.722839f or NaN */ - if (hx > 0x7f800000) /* NaN */ - return x; - if (!sign) { - /* overflow if x!=inf */ - STRICT_ASSIGN(float, x, x * 0x1p127f); + if (hx >= 0x42aeac50) { /* if |x| >= -87.33655f or NaN */ + if (hx >= 0x42b17218 && !sign) { /* x >= 88.722839f */ + /* overflow */ + x *= 0x1p127f; return x; } - if (hx == 0x7f800000) /* -inf */ - return 0; - if (hx >= 0x42cff1b5) { /* x <= -103.972084f */ + if (sign) { /* underflow */ - STRICT_ASSIGN(float, x, 0x1p-100f*0x1p-100f); - return x; + FORCE_EVAL(-0x1p-149f/x); + if (hx >= 0x42cff1b5) /* x <= -103.972084f */ + return 0; } } @@ -63,7 +60,7 @@ float expf(float x) k = 1 - sign - sign; hi = x - k*ln2hi; /* k*ln2hi is exact here */ lo = k*ln2lo; - STRICT_ASSIGN(float, x, hi - lo); + x = hi - lo; } else if (hx > 0x39000000) { /* |x| > 2**-14 */ k = 0; hi = x; @@ -77,8 +74,8 @@ float expf(float x) /* x is now in primary range */ xx = x*x; c = x - xx*(P1+xx*P2); - x = 1 + (x*c/(2-c) - lo + hi); + y = 1 + (x*c/(2-c) - lo + hi); if (k == 0) - return x; - return scalbnf(x, k); + return y; + return scalbnf(y, k); }