mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Cc: Petr Hosek <phosek@chromium.org>
Subject: [PATCH] math: fix expf(-NAN) to return -NAN instead of 0
Date: Fri, 4 Mar 2016 22:37:53 +0100	[thread overview]
Message-ID: <20160304213753.GM29662@port70.net> (raw)

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



             reply	other threads:[~2016-03-04 21:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-04 21:37 Szabolcs Nagy [this message]
2016-03-04 21:40 ` Szabolcs Nagy
2016-03-04 22:06 ` Szabolcs Nagy
2016-03-06  0:59   ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160304213753.GM29662@port70.net \
    --to=nsz@port70.net \
    --cc=musl@lists.openwall.com \
    --cc=phosek@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).