From owner-freebsd-numerics@FreeBSD.ORG Sun Aug 12 23:07:48 2012 Return-Path: Delivered-To: freebsd-numerics@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4AFB31065674 for ; Sun, 12 Aug 2012 23:07:48 +0000 (UTC) (envelope-from peter@rulingia.com) Received: from vps.rulingia.com (host-122-100-2-194.octopus.com.au [122.100.2.194]) by mx1.freebsd.org (Postfix) with ESMTP id D614A8FC18 for ; Sun, 12 Aug 2012 23:07:47 +0000 (UTC) Received: from server.rulingia.com (c220-239-249-137.belrs5.nsw.optusnet.com.au [220.239.249.137]) by vps.rulingia.com (8.14.5/8.14.5) with ESMTP id q7CN7laJ075730 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 13 Aug 2012 09:07:47 +1000 (EST) (envelope-from peter@rulingia.com) X-Bogosity: Ham, spamicity=0.000000 Received: from server.rulingia.com (localhost.rulingia.com [127.0.0.1]) by server.rulingia.com (8.14.5/8.14.5) with ESMTP id q7CN7fI8021406 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 13 Aug 2012 09:07:41 +1000 (EST) (envelope-from peter@server.rulingia.com) Received: (from peter@localhost) by server.rulingia.com (8.14.5/8.14.5/Submit) id q7CN7fWI021405 for freebsd-numerics@freebsd.org; Mon, 13 Aug 2012 09:07:41 +1000 (EST) (envelope-from peter) Resent-From: Peter Jeremy Resent-Date: Mon, 13 Aug 2012 09:07:41 +1000 Resent-Message-ID: <20120812230741.GB20453@server.rulingia.com> Resent-To: freebsd-numerics@freebsd.org Received: from vps.rulingia.com (host-122-100-2-194.octopus.com.au [122.100.2.194]) by server.rulingia.com (8.14.5/8.14.5) with ESMTP id q6IL9U0g005424 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 19 Jul 2012 07:09:31 +1000 (EST) (envelope-from stephen@missouri.edu) Received: from wilberforce.math.missouri.edu (wilberforce.math.missouri.edu [128.206.184.213]) by vps.rulingia.com (8.14.5/8.14.5) with ESMTP id q6IL9R7T078135 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 19 Jul 2012 07:09:30 +1000 (EST) (envelope-from stephen@missouri.edu) Received: from [127.0.0.1] (wilberforce.math.missouri.edu [128.206.184.213]) by wilberforce.math.missouri.edu (8.14.5/8.14.5) with ESMTP id q6IL96ot040144; Wed, 18 Jul 2012 16:09:06 -0500 (CDT) (envelope-from stephen@missouri.edu) Message-ID: <500725F2.7060603@missouri.edu> From: Stephen Montgomery-Smith Mail-Followup-To: freebsd-numerics@freebsd.org User-Agent: Mozilla/5.0 (X11; Linux i686; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 MIME-Version: 1.0 To: Steve Kargl References: <201207130818.38535.jhb@freebsd.org> <9EB2DA4F-19D7-4BA5-8811-D9451CB1D907@theravensnest.org> <20120713155805.GC81965@zim.MIT.EDU> <20120714120432.GA70706@server.rulingia.com> <20120717084457.U3890@besplex.bde.org> <5004A5C7.1040405@missouri.edu> <5004DEA9.1050001@missouri.edu> <20120717200931.U6624@besplex.bde.org> <5006D13D.2080702@missouri.edu> <20120718205625.GA409@troutmask.apl.washington.edu> In-Reply-To: <20120718205625.GA409@troutmask.apl.washington.edu> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Diane Bruce , John Baldwin , David Chisnall , Bruce Evans , Bruce Evans , David Schultz , Peter Jeremy , Warner Losh Subject: Re: Use of C99 extra long double math functions after r236148 X-BeenThere: freebsd-numerics@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussions of high quality implementation of libm functions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Date: Sun, 12 Aug 2012 23:07:48 -0000 X-Original-Date: Wed, 18 Jul 2012 16:09:06 -0500 X-List-Received-Date: Sun, 12 Aug 2012 23:07:48 -0000 On 07/18/2012 03:56 PM, Steve Kargl wrote: > On Wed, Jul 18, 2012 at 10:07:41AM -0500, Stephen Montgomery-Smith wrote: >> >>> The most obvious immediate difficulty in translating the above into C is >>> that y*y and z*z may overflow when the result shouldn't. >> >> This will be a lot easier than I originally expected. When we are in >> conditions when overflow might occur, we can simply make the approximations >> sqrt(y*y-1) = y >> csqrt(z*z+1) = signum(x)*z >> because in floating point arithmetic, these will not be approximations, >> but true exactly. And I am thinking that the test I will use for when >> to use these approximations will be (y==y+1) and (z==z+1) respectively. >> (I would use (z*z==z*z+1) but that test has the overflow problem.) > > I could be mistaken, but I believe that you need to raise the > inexact flag with these approximations because in fact you > are doing floating point math. > Thanks for this observation. I am looking through the C99 standard, trying to understand the inexact flag. But I am struggling to interpret it. Am I to understand that the inexact flag should be set anytime a floating point operation produces an answer that is not guaranteed exact? For example, should 1.0/3.0 and sqrt(2.0) raise the inexact flag?