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/expf.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/math/expf.c') diff --git a/src/math/expf.c b/src/math/expf.c index 16e9afe6..feee2b0e 100644 --- a/src/math/expf.c +++ b/src/math/expf.c @@ -39,6 +39,8 @@ float expf(float x) /* special cases */ if (hx >= 0x42aeac50) { /* if |x| >= -87.33655f or NaN */ + if (hx > 0x7f800000) /* NaN */ + return x; if (hx >= 0x42b17218 && !sign) { /* x >= 88.722839f */ /* overflow */ x *= 0x1p127f; -- cgit v1.2.1