From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12697 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: catan errors Date: Tue, 10 Apr 2018 16:50:32 -0400 Message-ID: <20180410205032.GL3094@brightrain.aerifal.cx> References: <20180410195007.GI3094@brightrain.aerifal.cx> <20180410203206.GJ3094@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1523393324 19414 195.159.176.226 (10 Apr 2018 20:48:44 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 10 Apr 2018 20:48:44 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-12713-gllmg-musl=m.gmane.org@lists.openwall.com Tue Apr 10 22:48:40 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 1f60Bx-0004u7-IE for gllmg-musl@m.gmane.org; Tue, 10 Apr 2018 22:48:37 +0200 Original-Received: (qmail 14121 invoked by uid 550); 10 Apr 2018 20:50:45 -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 14099 invoked from network); 10 Apr 2018 20:50:44 -0000 Content-Disposition: inline In-Reply-To: Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:12697 Archived-At: On Tue, Apr 10, 2018 at 05:41:46PM -0300, dgutson . wrote: > On Tue, Apr 10, 2018 at 5:32 PM, Rich Felker wrote: > > > On Tue, Apr 10, 2018 at 05:23:12PM -0300, dgutson . wrote: > > > On Tue, Apr 10, 2018 at 4:50 PM, Rich Felker wrote: > > > > > > > The OpenBSD catan implementation we're using has a number of > > > > nonsensical "overflow" (goto ovrf) conditions that aren't errors, > > > > reported by mepholic on irc. I think the attached patch fixes them > > > > without introducing new problems, but I'm not sure if any other > > > > problems remain. > > > > > > > > Note that, of the three cases removed: > > > > > > > > 1. Is not an exceptional case at all, and made no sense to begin with.. > > > > > > > > 2. Is only exceptional if x and a are both zero; atan(2x,0) is > > > > perfectly well-defined. > > > > > > > > 3. Is only possible if y==1.0 and x==0.0, which is the only real > > > > exceptional case for atan: z==I. > > > > > > > > > > > > > Besides the trigonometric case, are you considering de-normalized > > numbers, > > > such as 4.94066e-324 as divisor? > > > For example: > > > double x = 1.0; > > > double y = 5E-324; > > > x / y is inf, and y != 0.0. > > > Shouldn't 'a' be checked against that number or its absolute value >= > > > minimum? > > > > Can you clarify where you think something goes wrong? > > > > - if (a == 0.0) > - goto ovrf; > > t = y + 1.0; > a = (x2 + t * t)/a; > > > The check you removed does not look correct for me because what I mentioned.. > However, shouldn't you check, before the division, that a is not the > nearest to zero (+ or -) denormalized representable double, > in order to avoid ending in inf? Here a=x²+(y-1)², so unless both x==0 and y==1, the smallest a can be is DBL_EPSILON². When a is small, the numerator in the last line is also small (x²+(1+y)² < 2) so dividing by a does not overflow. Rich