提交 b023c03b 编写于 作者: S Szabolcs Nagy 提交者: Rich Felker

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.
上级 db66ef1f
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册