summaryrefslogtreecommitdiff
path: root/src/math/exp2f.c
diff options
context:
space:
mode:
authorSzabolcs Nagy <nsz@port70.net>2016-03-04 21:23:33 +0000
committerRich Felker <dalias@aerifal.cx>2016-03-04 17:58:49 -0500
commitb023c03b574acdfd73418314a5dcaa83e5cea5a0 (patch)
tree87a59e15a8cb6f344deb87a0f3cc88d31fefefea /src/math/exp2f.c
parentdb66ef1f7db7c5b672591a97a97bc789c9efe2f3 (diff)
downloadmusl-b023c03b574acdfd73418314a5dcaa83e5cea5a0.tar.gz
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.
Diffstat (limited to 'src/math/exp2f.c')
-rw-r--r--src/math/exp2f.c2
1 files changed, 2 insertions, 0 deletions
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;