mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH] math: fix expf(-NAN) to return -NAN instead of 0
@ 2016-03-04 21:37 Szabolcs Nagy
  2016-03-04 21:40 ` Szabolcs Nagy
  2016-03-04 22:06 ` Szabolcs Nagy
  0 siblings, 2 replies; 4+ messages in thread
From: Szabolcs Nagy @ 2016-03-04 21:37 UTC (permalink / raw)
  To: musl; +Cc: Petr Hosek

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(+)

diff --git a/src/math/expf.c b/src/math/expf.c
index 16e9afe..4a742e4 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;
-- 
2.7.0



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-03-06  0:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-04 21:37 [PATCH] math: fix expf(-NAN) to return -NAN instead of 0 Szabolcs Nagy
2016-03-04 21:40 ` Szabolcs Nagy
2016-03-04 22:06 ` Szabolcs Nagy
2016-03-06  0:59   ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).