Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 4 Mar 2016 22:40:31 +0100
From: Szabolcs Nagy <nsz@...t70.net>
To: musl@...ts.openwall.com, Petr Hosek <phosek@...omium.org>
Subject: Re: [PATCH] math: fix expf(-NAN) to return -NAN instead of 0

* Szabolcs Nagy <nsz@...t70.net> [2016-03-04 22:37:53 +0100]:
> 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 */

in the comment -87... should be 87...
but i didnt want to include that into the bug fix

> +		if (hx > 0x7f800000) /* +-NaN */
> +			return x;
>  		if (hx >= 0x42b17218 && !sign) {  /* x >= 88.722839f */
>  			/* overflow */
>  			x *= 0x1p127f;
> -- 
> 2.7.0

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.