From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/9462 Path: news.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH] math: fix expf(-NAN) to return -NAN instead of 0 Date: Fri, 4 Mar 2016 22:37:53 +0100 Message-ID: <20160304213753.GM29662@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1457127498 6347 80.91.229.3 (4 Mar 2016 21:38:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 4 Mar 2016 21:38:18 +0000 (UTC) Cc: Petr Hosek To: musl@lists.openwall.com Original-X-From: musl-return-9475-gllmg-musl=m.gmane.org@lists.openwall.com Fri Mar 04 22:38:17 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1abxQN-0003Ik-NZ for gllmg-musl@m.gmane.org; Fri, 04 Mar 2016 22:38:15 +0100 Original-Received: (qmail 1851 invoked by uid 550); 4 Mar 2016 21:38:11 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 1787 invoked from network); 4 Mar 2016 21:38:05 -0000 Mail-Followup-To: musl@lists.openwall.com, Petr Hosek Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Xref: news.gmane.org gmane.linux.lib.musl.general:9462 Archived-At: 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