From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12703 Path: news.gmane.org!.POSTED!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: catan errors Date: Wed, 11 Apr 2018 02:52:11 +0200 Message-ID: <20180411005211.GL4418@port70.net> References: <20180410195007.GI3094@brightrain.aerifal.cx> <20180410230849.GK4418@port70.net> <20180410232328.GN3094@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1523407820 25891 195.159.176.226 (11 Apr 2018 00:50:20 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 11 Apr 2018 00:50:20 +0000 (UTC) User-Agent: Mutt/1.9.1 (2017-09-22) To: musl@lists.openwall.com Original-X-From: musl-return-12719-gllmg-musl=m.gmane.org@lists.openwall.com Wed Apr 11 02:50:16 2018 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1f63xo-0006dT-E1 for gllmg-musl@m.gmane.org; Wed, 11 Apr 2018 02:50:16 +0200 Original-Received: (qmail 11817 invoked by uid 550); 11 Apr 2018 00:52:23 -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 11799 invoked from network); 11 Apr 2018 00:52:23 -0000 Mail-Followup-To: musl@lists.openwall.com Content-Disposition: inline In-Reply-To: <20180410232328.GN3094@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:12703 Archived-At: * Rich Felker [2018-04-10 19:23:28 -0400]: > On Wed, Apr 11, 2018 at 01:08:50AM +0200, Szabolcs Nagy wrote: > > * Rich Felker [2018-04-10 15:50:07 -0400]: > > > t = y - 1.0; > > > a = x2 + (t * t); > > > - if (a == 0.0) > > > - goto ovrf; > > > > why does a==0 imply x==0? > > OK, at least by my reasoning it's only algebraically true not > necessarily as doubles. > > > if |x| < sqrt(2)*0x1p-538, x2 underflows to 0 in nearest rounding mode. > > > > to handle this correctly extra work would need to be done, so i think > > either way is fine (leaving the goto there or not are both wrong, but > > we dont guarantee correct complex functions yet) > > I'm fine with just moving the check back here. But the special case > (maybe not near-special cases with internal over/underflow though) > works fine just replacing the *I with CMPLX. See attached. > i think this makes sense for now. > Rich > diff --git a/src/complex/catan.c b/src/complex/catan.c > index 39ce6cf..7dc2afe 100644 > --- a/src/complex/catan.c > +++ b/src/complex/catan.c > @@ -91,29 +91,17 @@ double complex catan(double complex z) > x = creal(z); > y = cimag(z); > > - if (x == 0.0 && y > 1.0) > - goto ovrf; > - > x2 = x * x; > a = 1.0 - x2 - (y * y); > - if (a == 0.0) > - goto ovrf; > > t = 0.5 * atan2(2.0 * x, a); > w = _redupi(t); > > t = y - 1.0; > a = x2 + (t * t); > - if (a == 0.0) > - goto ovrf; > > t = y + 1.0; > a = (x2 + t * t)/a; > - w = w + (0.25 * log(a)) * I; > - return w; > - > -ovrf: > - // FIXME > - w = MAXNUM + MAXNUM * I; > + w = CMPLX(w, 0.25 * log(a)); > return w; > }