From owner-freebsd-numerics@FreeBSD.ORG Mon Jun 17 11:06:49 2013 Return-Path: Delivered-To: freebsd-numerics@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 66B441F1 for ; Mon, 17 Jun 2013 11:06:49 +0000 (UTC) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id 58CCA1C18 for ; Mon, 17 Jun 2013 11:06:49 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.7/8.14.7) with ESMTP id r5HB6nAJ012812 for ; Mon, 17 Jun 2013 11:06:49 GMT (envelope-from owner-bugmaster@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.7/8.14.7/Submit) id r5HB6mHq012810 for freebsd-numerics@FreeBSD.org; Mon, 17 Jun 2013 11:06:48 GMT (envelope-from owner-bugmaster@FreeBSD.org) Date: Mon, 17 Jun 2013 11:06:48 GMT Message-Id: <201306171106.r5HB6mHq012810@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: gnats set sender to owner-bugmaster@FreeBSD.org using -f From: FreeBSD bugmaster To: freebsd-numerics@FreeBSD.org Subject: Current problem reports assigned to freebsd-numerics@FreeBSD.org X-BeenThere: freebsd-numerics@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Discussions of high quality implementation of libm functions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Jun 2013 11:06:49 -0000 Note: to view an individual PR, use: http://www.freebsd.org/cgi/query-pr.cgi?pr=(number). The following is a listing of current problems submitted by FreeBSD users. These represent problem reports covering all versions including experimental development code and obsolete releases. S Tracker Resp. Description -------------------------------------------------------------------------------- o stand/175811 numerics libstdc++ needs complex support in order use C99 o bin/170206 numerics [msun] [patch] complex arcsinh, log, etc. o stand/82654 numerics C99 long double math functions are missing 3 problems total. From owner-freebsd-numerics@FreeBSD.ORG Mon Jun 17 23:29:50 2013 Return-Path: Delivered-To: freebsd-numerics@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id A9A7BA74; Mon, 17 Jun 2013 23:29:50 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail12.syd.optusnet.com.au (mail12.syd.optusnet.com.au [211.29.132.193]) by mx1.freebsd.org (Postfix) with ESMTP id 4597017B6; Mon, 17 Jun 2013 23:29:49 +0000 (UTC) Received: from c122-106-156-23.carlnfd1.nsw.optusnet.com.au (c122-106-156-23.carlnfd1.nsw.optusnet.com.au [122.106.156.23]) by mail12.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id r5HNTfDW017625 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 18 Jun 2013 09:29:42 +1000 Date: Tue, 18 Jun 2013 09:29:41 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: David Schultz Subject: Re: Implementation for coshl. In-Reply-To: <20130610055834.GA68643@zim.MIT.EDU> Message-ID: <20130618091306.A787@besplex.bde.org> References: <20130610003645.GA16444@troutmask.apl.washington.edu> <20130610110740.V24058@besplex.bde.org> <20130610055834.GA68643@zim.MIT.EDU> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.0 cv=Q6eKePKa c=1 sm=1 a=LM0AswAWfpYA:10 a=kj9zAlcOel0A:10 a=PO7r1zJSAAAA:8 a=JzwRw_2MAAAA:8 a=MtpAjnDH-vAA:10 a=LZ7Z3jF9hK5WwFTye5kA:9 a=CjuIK1q_8ugA:10 a=ebeQFi2P/qHVC0Yw9JDJ4g==:117 Cc: freebsd-numerics@FreeBSD.org, Steve Kargl X-BeenThere: freebsd-numerics@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Discussions of high quality implementation of libm functions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Jun 2013 23:29:50 -0000 [Reply to my latest saved mail in this thread. Mostly not in response to it.] On Sun, 9 Jun 2013, David Schultz wrote: > On Mon, Jun 10, 2013, Bruce Evans wrote: >> On Sun, 9 Jun 2013, Steve Kargl wrote: >>> The former would require a refactoring of >>> s_expl.c into a kernel __kernel_expl(x, hi, lo). I have no plans on >>> pursuing this at the this time. >> >> But you need this soon for __ldexp_exp() and __ldexp_cexp(), which are >> needed for hyperbolic functions (the large args already fixed for float >> and double precision) and for cexp() and trig and hyperbolic complex >> functions. It is much easier to implement these using a kernel. I do >> this only for float precision. > > That's fine for now. We need a better k_exp, too. I believe > Bruce was working on one. The wrappers turned out to be fairly easy. Especially __ldexp_exp*(() and __ldexp_cexp*(), given the main wrapper. Are you going to finish coshl() and sinhl()? I'm getting closer to hacking on them. I'm now in the middle of doing this for cosh(): diff -u2 e_cosh.c~ e_cosh.c % --- e_cosh.c~ Thu May 30 18:14:16 2013 % +++ e_cosh.c Mon Jun 17 23:54:12 2013 % @@ -39,10 +39,23 @@ % #include "math_private.h" % % -static const double one = 1.0, half=0.5, huge = 1.0e300; % +static const double one = 1.0, half = 0.5; % +static const volatile double huge = 1.0e300, tiny = 1.0e-300; Part of fixing old bugs. % +static const double % +/* % + * Domain [-1, 1], range ~[-2.2746e-18, 2.2748e-18]: % + * |cosh(x) - c(x)| < 2**-58.6 % + */ % +C2 = 5.0000000000000000e-1, /* 0x10000000000000.0p-53 */ % +C4 = 4.1666666666665422e-2, /* 0x155555555554a2.0p-57 */ % +C6 = 1.3888888889057476e-3, /* 0x16c16c16c29bca.0p-62 */ % +C8 = 2.4801587216389553e-5, /* 0x1a01a01881edc9.0p-68 */ % +C10 = 2.7557340350974160e-7, /* 0x127e50a5570530.0p-74 */ % +C12 = 2.0873996906899188e-9, /* 0x11ee3d8f036513.0p-81 */ % +C14 = 1.1653016291730710e-11; /* 0x19a010a270ce5a.0p-89 */ New method for small x. % % double % __ieee754_cosh(double x) % { % - double t,w; % + double_t t,x2; % int32_t ix; % double -> double_t prepares for using the kernel and avoids discarding accuracy on i386. % @@ -54,13 +67,14 @@ % if(ix>=0x7ff00000) return x*x; % % - /* |x| in [0,0.5*ln2], return 1+expm1(|x|)^2/(2*exp(|x|)) */ % - if(ix<0x3fd62e43) { % - t = expm1(fabs(x)); % - w = one+t; % - if (ix<0x3c800000) return w; /* cosh(tiny) = 1 */ % - return one+(t*t)/(w+w); % + /* |x| in [0,1), return 1 or c(x) */ Fix comment to match code. Update it for new code. % + if(ix<0x3ff00000) { % + if (ix<0x3c800000) % + return one+tiny; /* cosh(tiny) = 1(+) with inexact */ Fix minor bugs in setting inexact % + x2 = x*x; % + return x2*x2*(x2*x2*x2*(x2*(x2*C14 + C12) + C10) + % + x2*(x2*C8 + C6) + C4) + x2*C2 + 1; More accuracy for |x| < 1. % } % % - /* |x| in [0.5*ln2,22], return (exp(|x|)+1/exp(|x|)/2; */ % + /* |x| in [1,22], return (exp(|x|)+1/exp(|x|)/2; */ % if (ix < 0x40360000) { % t = __ieee754_exp(fabs(x)); I just need to change this and later cases to use the kernel and its wrappers. In float precision, this is: % - /* |x| in [0.5*ln2,9], return (exp(|x|)+1/exp(|x|))/2; */ % - if (ix < 0x41100000) { % - t = __ieee754_expf(fabsf(x)); % - return half*t+half/t; % + /* |x| in [1, 12), return accurate exp(|x|)/2+1/exp(|x|)/2 */ % + if (ix<0x41400000) { % + k_hexpf(fabsf(x), &hi, &lo); % + return lo + 0.25F/(hi + lo) + hi; % } Bruce From owner-freebsd-numerics@FreeBSD.ORG Mon Jun 17 23:47:26 2013 Return-Path: Delivered-To: freebsd-numerics@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 65F61C5B; Mon, 17 Jun 2013 23:47:26 +0000 (UTC) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.95.76.21]) by mx1.freebsd.org (Postfix) with ESMTP id 4A3A41845; Mon, 17 Jun 2013 23:47:26 +0000 (UTC) Received: from troutmask.apl.washington.edu (localhost.apl.washington.edu [127.0.0.1]) by troutmask.apl.washington.edu (8.14.6/8.14.6) with ESMTP id r5HNlJeL039221; Mon, 17 Jun 2013 16:47:19 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.14.6/8.14.6/Submit) id r5HNlJEf039220; Mon, 17 Jun 2013 16:47:19 -0700 (PDT) (envelope-from sgk) Date: Mon, 17 Jun 2013 16:47:19 -0700 From: Steve Kargl To: Bruce Evans Subject: Re: Implementation for coshl. Message-ID: <20130617234719.GA11552@troutmask.apl.washington.edu> References: <20130610003645.GA16444@troutmask.apl.washington.edu> <20130610110740.V24058@besplex.bde.org> <20130610055834.GA68643@zim.MIT.EDU> <20130618091306.A787@besplex.bde.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130618091306.A787@besplex.bde.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: David Schultz , freebsd-numerics@FreeBSD.org X-BeenThere: freebsd-numerics@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Discussions of high quality implementation of libm functions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Jun 2013 23:47:26 -0000 On Tue, Jun 18, 2013 at 09:29:41AM +1000, Bruce Evans wrote: > [Reply to my latest saved mail in this thread. Mostly not in response to it.] > > On Sun, 9 Jun 2013, David Schultz wrote: > > > On Mon, Jun 10, 2013, Bruce Evans wrote: > >> On Sun, 9 Jun 2013, Steve Kargl wrote: > > >>> The former would require a refactoring of > >>> s_expl.c into a kernel __kernel_expl(x, hi, lo). I have no plans on > >>> pursuing this at the this time. > >> > >> But you need this soon for __ldexp_exp() and __ldexp_cexp(), which are > >> needed for hyperbolic functions (the large args already fixed for float > >> and double precision) and for cexp() and trig and hyperbolic complex > >> functions. It is much easier to implement these using a kernel. I do > >> this only for float precision. > > > > That's fine for now. We need a better k_exp, too. I believe > > Bruce was working on one. > > The wrappers turned out to be fairly easy. Especially __ldexp_exp*(() > and __ldexp_cexp*(), given the main wrapper. > > Are you going to finish coshl() and sinhl()? I'm getting closer to > hacking on them. I'm now in the middle of doing this for cosh(): I won't have time until mid-July to work on coshl, sinhl, and tanhl. I leave for an underwater acoustic conference in Greece on Friday, and do not return until the 1st week of July. > > diff -u2 e_cosh.c~ e_cosh.c > % --- e_cosh.c~ Thu May 30 18:14:16 2013 > % +++ e_cosh.c Mon Jun 17 23:54:12 2013 I'll lookover the rest of this tonight. -- Steve From owner-freebsd-numerics@FreeBSD.ORG Tue Jun 18 02:17:23 2013 Return-Path: Delivered-To: freebsd-numerics@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 300D1B09; Tue, 18 Jun 2013 02:17:23 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail109.syd.optusnet.com.au (mail109.syd.optusnet.com.au [211.29.132.80]) by mx1.freebsd.org (Postfix) with ESMTP id E506E1F8A; Tue, 18 Jun 2013 02:17:22 +0000 (UTC) Received: from c122-106-156-23.carlnfd1.nsw.optusnet.com.au (c122-106-156-23.carlnfd1.nsw.optusnet.com.au [122.106.156.23]) by mail109.syd.optusnet.com.au (Postfix) with ESMTPS id 55AFE123BFD; Tue, 18 Jun 2013 12:17:21 +1000 (EST) Date: Tue, 18 Jun 2013 12:17:19 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Steve Kargl Subject: Re: Implementation for coshl. In-Reply-To: <20130617234719.GA11552@troutmask.apl.washington.edu> Message-ID: <20130618121132.V1852@besplex.bde.org> References: <20130610003645.GA16444@troutmask.apl.washington.edu> <20130610110740.V24058@besplex.bde.org> <20130610055834.GA68643@zim.MIT.EDU> <20130618091306.A787@besplex.bde.org> <20130617234719.GA11552@troutmask.apl.washington.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.0 cv=Q6eKePKa c=1 sm=1 a=LM0AswAWfpYA:10 a=kj9zAlcOel0A:10 a=PO7r1zJSAAAA:8 a=JzwRw_2MAAAA:8 a=MtpAjnDH-vAA:10 a=kCBc9LMQr5lOMOd8EzYA:9 a=CjuIK1q_8ugA:10 a=ebeQFi2P/qHVC0Yw9JDJ4g==:117 Cc: David Schultz , freebsd-numerics@FreeBSD.org X-BeenThere: freebsd-numerics@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Discussions of high quality implementation of libm functions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Jun 2013 02:17:23 -0000 On Mon, 17 Jun 2013, Steve Kargl wrote: > On Tue, Jun 18, 2013 at 09:29:41AM +1000, Bruce Evans wrote: >> ... >> Are you going to finish coshl() and sinhl()? I'm getting closer to >> hacking on them. I'm now in the middle of doing this for cosh(): > > I won't have time until mid-July to work on coshl, sinhl, and tanhl. > I leave for an underwater acoustic conference in Greece on Friday, > and do not return until the 1st week of July. Send what you have and I will complete it in a few days. I will probably merge it into versions derived from the fdlibm ones and use fdlibm style. Bruce From owner-freebsd-numerics@FreeBSD.ORG Wed Jun 19 19:54:06 2013 Return-Path: Delivered-To: freebsd-numerics@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id B6C932DA for ; Wed, 19 Jun 2013 19:54:06 +0000 (UTC) (envelope-from lists@eitanadler.com) Received: from mail-pa0-x236.google.com (mail-pa0-x236.google.com [IPv6:2607:f8b0:400e:c03::236]) by mx1.freebsd.org (Postfix) with ESMTP id 9453A1BAC for ; Wed, 19 Jun 2013 19:54:06 +0000 (UTC) Received: by mail-pa0-f54.google.com with SMTP id kx10so5481943pab.41 for ; Wed, 19 Jun 2013 12:54:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eitanadler.com; s=0xdeadbeef; h=mime-version:from:date:message-id:subject:to:content-type; bh=qWoiqpYfkvP/tAaOeJk27O6a1Xlln9WZnIkVu+cqThU=; b=oOq+5OYywWaaGAfI0yybQUDgQzvP2niYQQ6RW96l9lllImxgddEYrMboXV7KVgbkqm 7pBUmenUjahv6gGqNltrTvaeOdpiqturfVfdP23xMFaHKH15MuC6enZ0qIbr0LzVYPsu CrWoHe+9y0PS70JdCDfmLpu7lo9AeZrl7tvP0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type :x-gm-message-state; bh=qWoiqpYfkvP/tAaOeJk27O6a1Xlln9WZnIkVu+cqThU=; b=NVE+BjYTB9AH1+O4wuFVH6Y6CbTs4veOEwJupePAVDI9CYs2aDptWuStckt/UsL8Ot //fmHyEzt95/xHKCT9XCc8xZ8zZtcoAHn5f6qc+1jr6SHiLNSqc+NJ2u1z2tRmkgyB5z QIXldbY6zJdeUrpkJxLGD9e0/TgZx9TjF81rOkMcbvzmLqv+Xoi8NN0lIUvHiybmHg2z 4KyBrBLGIOo+7ZAh3zLq8FeKJ7DSiLeugoANMo+GbPjvwJqaMMl84gZbt7++G6HyZysg cHkCEShwO1kpvq+CMKbmKngCwXsuDWrFlcVQfGBAdtWr0RE5gNhdQGryTMoNg8YtkCNp Ti7g== X-Received: by 10.66.240.70 with SMTP id vy6mr8415608pac.70.1371671646375; Wed, 19 Jun 2013 12:54:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.70.45.33 with HTTP; Wed, 19 Jun 2013 12:53:35 -0700 (PDT) From: Eitan Adler Date: Wed, 19 Jun 2013 21:53:35 +0200 Message-ID: Subject: operation precedence bug: lib/msun/src To: freebsd-numerics@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Gm-Message-State: ALoCoQlil8OYbEVztpEJFHRVvzV3dPlJJjrIMXNUaODFXhKgsUx4TUanD26Ti0vPg25KWm9MkQR3 X-BeenThere: freebsd-numerics@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Discussions of high quality implementation of libm functions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Jun 2013 19:54:06 -0000 Does the following look correct? commit 8314bb5309d86bd780c49549eb6a6c43cc9f2fff Author: Eitan Adler Date: Wed Jun 19 21:51:05 2013 +0200 Fix operation precedence bug: != comes before ^ so add required parens Reported by: swildner@DragonFlyBSD.org Reviewed by: swildner@DragonFlyBSD.org Reviewed by: dim, freebsd-numerics@ diff --git a/lib/msun/src/s_fma.c b/lib/msun/src/s_fma.c index 452bece..406ff47 100644 --- a/lib/msun/src/s_fma.c +++ b/lib/msun/src/s_fma.c @@ -117,7 +117,7 @@ add_and_denormalize(double a, double b, int scale) if (sum.lo != 0) { EXTRACT_WORD64(hibits, sum.hi); bits_lost = -((int)(hibits >> 52) & 0x7ff) - scale + 1; - if (bits_lost != 1 ^ (int)(hibits & 1)) { + if (bits_lost != (1 ^ (int)(hibits & 1))) { /* hibits += (int)copysign(1.0, sum.hi * sum.lo) */ EXTRACT_WORD64(lobits, sum.lo); hibits += 1 - (((hibits ^ lobits) >> 62) & 2); diff --git a/lib/msun/src/s_fmal.c b/lib/msun/src/s_fmal.c index 9271901..ec4cc4d 100644 --- a/lib/msun/src/s_fmal.c +++ b/lib/msun/src/s_fmal.c @@ -113,7 +113,7 @@ add_and_denormalize(long double a, long double b, int scale) if (sum.lo != 0) { u.e = sum.hi; bits_lost = -u.bits.exp - scale + 1; - if (bits_lost != 1 ^ (int)(u.bits.manl & 1)) + if (bits_lost != (1 ^ (int)(u.bits.manl & 1))) sum.hi = nextafterl(sum.hi, INFINITY * sum.lo); } return (ldexp(sum.hi, scale)); -- Eitan Adler From owner-freebsd-numerics@FreeBSD.ORG Wed Jun 19 22:06:40 2013 Return-Path: Delivered-To: freebsd-numerics@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 83D7EC1E for ; Wed, 19 Jun 2013 22:06:40 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail105.syd.optusnet.com.au (mail105.syd.optusnet.com.au [211.29.132.249]) by mx1.freebsd.org (Postfix) with ESMTP id 4C2391233 for ; Wed, 19 Jun 2013 22:06:39 +0000 (UTC) Received: from c122-106-156-23.carlnfd1.nsw.optusnet.com.au (c122-106-156-23.carlnfd1.nsw.optusnet.com.au [122.106.156.23]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id 155E21041C6F; Thu, 20 Jun 2013 08:06:32 +1000 (EST) Date: Thu, 20 Jun 2013 08:06:31 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Eitan Adler Subject: Re: operation precedence bug: lib/msun/src In-Reply-To: Message-ID: <20130620071226.L1067@besplex.bde.org> References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.0 cv=Q6eKePKa c=1 sm=1 a=JW1MbwKkIIsA:10 a=kj9zAlcOel0A:10 a=PO7r1zJSAAAA:8 a=JzwRw_2MAAAA:8 a=vqevWRgFEOoA:10 a=4iUgboIlSR6cpcxLKlUA:9 a=CjuIK1q_8ugA:10 a=fxujCl1df8CZ5cHc:21 a=AExpOoHPGUjUhLgS:21 a=ebeQFi2P/qHVC0Yw9JDJ4g==:117 Cc: freebsd-numerics@freebsd.org X-BeenThere: freebsd-numerics@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Discussions of high quality implementation of libm functions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Jun 2013 22:06:40 -0000 On Wed, 19 Jun 2013, Eitan Adler wrote: > Does the following look correct? No :-). > Fix operation precedence bug: != comes before ^ so add required parens According to das, the code was correct, though unclear. The change adds unrequired parentheses. Since these are in the wrong place, they change the object code and probably break it. > diff --git a/lib/msun/src/s_fma.c b/lib/msun/src/s_fma.c > index 452bece..406ff47 100644 > --- a/lib/msun/src/s_fma.c > +++ b/lib/msun/src/s_fma.c > @@ -117,7 +117,7 @@ add_and_denormalize(double a, double b, int scale) > if (sum.lo != 0) { > EXTRACT_WORD64(hibits, sum.hi); > bits_lost = -((int)(hibits >> 52) & 0x7ff) - scale + 1; > - if (bits_lost != 1 ^ (int)(hibits & 1)) { > + if (bits_lost != (1 ^ (int)(hibits & 1))) { > /* hibits += (int)copysign(1.0, sum.hi * sum.lo) */ > EXTRACT_WORD64(lobits, sum.lo); > hibits += 1 - (((hibits ^ lobits) >> 62) & 2); > diff --git a/lib/msun/src/s_fmal.c b/lib/msun/src/s_fmal.c > index 9271901..ec4cc4d 100644 > --- a/lib/msun/src/s_fmal.c > +++ b/lib/msun/src/s_fmal.c > @@ -113,7 +113,7 @@ add_and_denormalize(long double a, long double b, int scale) > if (sum.lo != 0) { > u.e = sum.hi; > bits_lost = -u.bits.exp - scale + 1; > - if (bits_lost != 1 ^ (int)(u.bits.manl & 1)) > + if (bits_lost != (1 ^ (int)(u.bits.manl & 1))) > sum.hi = nextafterl(sum.hi, INFINITY * sum.lo); > } > return (ldexp(sum.hi, scale)); I use the following fix (put the parentheses in the right place), but haven't actually tested it: % diff -u2 s_fma.c~ s_fma.c % --- s_fma.c~ Thu May 30 18:15:37 2013 % +++ s_fma.c Thu May 30 18:15:38 2013 % @@ -118,5 +118,5 @@ % EXTRACT_WORD64(hibits, sum.hi); % bits_lost = -((int)(hibits >> 52) & 0x7ff) - scale + 1; % - if (bits_lost != 1 ^ (int)(hibits & 1)) { % + if ((bits_lost != 1) ^ (int)(hibits & 1)) { % /* hibits += (int)copysign(1.0, sum.hi * sum.lo) */ % EXTRACT_WORD64(lobits, sum.lo); % diff -u2 s_fmal.c~ s_fmal.c % --- s_fmal.c~ Thu May 30 18:16:08 2013 % +++ s_fmal.c Thu May 30 18:16:09 2013 % @@ -114,5 +114,5 @@ % u.e = sum.hi; % bits_lost = -u.bits.exp - scale + 1; % - if (bits_lost != 1 ^ (int)(u.bits.manl & 1)) % + if ((bits_lost != 1) ^ (int)(u.bits.manl & 1)) % sum.hi = nextafterl(sum.hi, INFINITY * sum.lo); % } Bruce