From b023c03b574acdfd73418314a5dcaa83e5cea5a0 Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Fri, 4 Mar 2016 21:23:33 +0000 Subject: math: fix expf(-NAN) and exp2f(-NAN) to return -NAN instead of 0 expf(-NAN) was treated as expf(-large) which unconditionally returns +0, so special case +-NAN. reported by Petr Hosek. --- src/math/exp2f.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/math/exp2f.c') diff --git a/src/math/exp2f.c b/src/math/exp2f.c index cf6126ee..296b6343 100644 --- a/src/math/exp2f.c +++ b/src/math/exp2f.c @@ -91,6 +91,8 @@ float exp2f(float x) /* Filter out exceptional cases. */ ix = u.i & 0x7fffffff; if (ix > 0x42fc0000) { /* |x| > 126 */ + if (ix > 0x7f800000) /* NaN */ + return x; if (u.i >= 0x43000000 && u.i < 0x80000000) { /* x >= 128 */ x *= 0x1p127f; return x; -- cgit v1.2.1