From 39c910fb061114e6aa5c3bf2c94b1d7262d62221 Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Wed, 4 Sep 2013 07:51:11 +0000 Subject: math: fix underflow in exp*.c and long double handling in exp2l * don't care about inexact flag * use double_t and float_t (faster, smaller, more precise on x86) * exp: underflow when result is zero or subnormal and not -inf * exp2: underflow when result is zero or subnormal and not exact * expm1: underflow when result is zero or subnormal * expl: don't underflow on -inf * exp2: fix incorrect comment * expm1: simplify special case handling and overflow properly * expm1: cleanup final scaling and fix negative left shift ub (twopk) --- src/math/expl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/math/expl.c') diff --git a/src/math/expl.c b/src/math/expl.c index 50a04297..b62980fa 100644 --- a/src/math/expl.c +++ b/src/math/expl.c @@ -100,7 +100,7 @@ long double expl(long double x) if (x > 11356.5234062941439488L) /* x > ln(2^16384 - 0.5) */ return x * 0x1p16383L; if (x < -11399.4985314888605581L) /* x < ln(2^-16446) */ - return 0x1p-10000L * 0x1p-10000L; + return -0x1p-16445L/x; /* Express e**x = e**f 2**k * = e**(f + k ln(2)) -- cgit v1.2.1