diff options
author | nsz <nsz@port70.net> | 2012-03-19 22:57:58 +0100 |
---|---|---|
committer | nsz <nsz@port70.net> | 2012-03-19 22:57:58 +0100 |
commit | 2786c7d21611b9fa3b2fe356542cf213e7dd0ba4 (patch) | |
tree | b3954e9cec7580f5dc851491d3b60d808aae4259 /src/math/expl.c | |
parent | 01fdfd491b5d83b72099fbae14c4a71ed8e0b945 (diff) | |
download | musl-2786c7d21611b9fa3b2fe356542cf213e7dd0ba4.tar.gz musl-2786c7d21611b9fa3b2fe356542cf213e7dd0ba4.tar.xz musl-2786c7d21611b9fa3b2fe356542cf213e7dd0ba4.zip |
use scalbn or *2.0 instead of ldexp, fix fmal
Some code assumed ldexp(x, 1) is faster than 2.0*x, but ldexp is a wrapper around scalbn which uses multiplications inside, so this optimization is wrong. This commit also fixes fmal which accidentally used ldexp instead of ldexpl loosing precision. There are various additional changes from the work-in-progress const cleanups.
Diffstat (limited to 'src/math/expl.c')
-rw-r--r-- | src/math/expl.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/math/expl.c b/src/math/expl.c index 9507fd2e..b289ffec 100644 --- a/src/math/expl.c +++ b/src/math/expl.c @@ -102,13 +102,13 @@ long double expl(long double x) if (x > MAXLOGL) return INFINITY; if (x < MINLOGL) - return 0.0L; + return 0.0; /* Express e**x = e**g 2**n * = e**g e**(n loge(2)) * = e**(g + n loge(2)) */ - px = floorl(LOG2EL * x + 0.5L); /* floor() truncates toward -infinity. */ + px = floorl(LOG2EL * x + 0.5); /* floor() truncates toward -infinity. */ n = px; x -= px * C1; x -= px * C2; @@ -120,8 +120,8 @@ long double expl(long double x) xx = x * x; px = x * __polevll(xx, P, 2); x = px/(__polevll(xx, Q, 3) - px); - x = 1.0L + ldexpl(x, 1); - x = ldexpl(x, n); + x = 1.0 + 2.0 * x; + x = scalbnl(x, n); return x; } #endif |