From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/783 Path: news.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: math todo Date: Tue, 1 May 2012 20:33:56 +0200 Message-ID: <20120501183356.GL16237@port70.net> References: <20120501000503.GI16237@port70.net> <20120501011921.GK14673@brightrain.aerifal.cx> <20120501091458.GJ16237@port70.net> <20120501144438.GL14673@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1335897250 613 80.91.229.3 (1 May 2012 18:34:10 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 1 May 2012 18:34:10 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-784-gllmg-musl=m.gmane.org@lists.openwall.com Tue May 01 20:34:09 2012 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1SPHtp-0008US-7B for gllmg-musl@plane.gmane.org; Tue, 01 May 2012 20:34:09 +0200 Original-Received: (qmail 18258 invoked by uid 550); 1 May 2012 18:34:08 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 18250 invoked from network); 1 May 2012 18:34:08 -0000 Content-Disposition: inline In-Reply-To: <20120501144438.GL14673@brightrain.aerifal.cx> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:783 Archived-At: * Rich Felker [2012-05-01 10:44:38 -0400]: > On Tue, May 01, 2012 at 11:14:58AM +0200, Szabolcs Nagy wrote: > > yes, actually > > fesetround(FE_UPWARD); > > exp(-inf) =3D 0x1p-1074; // smallest subnormal > > instead of 0, which is 1ulp depending on your definition of ulp :) >=20 > This is incorrect (because the result is exact, the error is =3D=3D1ulp, > and IEEE requires <1ulp). But for the large finite negative arguments, > 0x1p-1074 is the correctly rounded answer in rounds-upward mode. >=20 ok > > > BTW under asm, we may also want to switch to the faster acos > > > implementation. > > ok i'll add it > > (for double it is known to work, but i havent tested it for > > the long double case) >=20 > Even if we can't switch ld we could still switch it for the > float/double versions and keep our original asm for ld80. >=20 ok > All of the nextafter stuff looks overly complicated. Shouldn't these > functions all just be (essentially): >=20 > if (x>y) rep_x--; > else if (x=20 > modulo a little handling for sign and =B10? >=20 yes and that's what is done, but under/overflow flags are also handled and for double two uint32_t is used instead of one uint64_t ++ (and comparision is done using int instead of float compare) it can be a bit simpler > > 99 ulp want: 0 got: 8000000000000000 round: m acos ar= g0: 0x1p+0 arg1: 0x0p+0 want: 0x0p+0 got: -0x0p+0 > > 99 ulp want: 8000000000000000 got: 8000000000000001 round: p atan ar= g0: -0x1p-1074 arg1: 0x0p+0 want: -0x0p+0 got: -0x1p-1074 > > 99 ulp want: 0 got: 1 round: m atan ar= g0: 0x1p-1074 arg1: 0x0p+0 want: 0x0p+0 got: 0x1p-1074 > > 99 ulp want: 0 got: 1 round: z atan ar= g0: 0x1p-1074 arg1: 0x0p+0 want: 0x0p+0 got: 0x1p-1074 > > 99 ulp want: 8000000000000000 got: 8000000000000001 round: z atan ar= g0: -0x1p-1074 arg1: 0x0p+0 want: -0x0p+0 got: -0x1p-1074 >=20 > IMO this is 1ulp not >99ulp. For denormals ulp is not x * 0x1p-52 but > the actual last place of significance. >=20 yes it is 1ulp, but it's a huge relative error, same for sign differences > > all: 69734 fail: 12787 failbad: 107 failepic: 72 >=20 > Like your choice of naming. :-) :)