Date: Sun, 12 Aug 2012 23:07:34 -0000 From: Steve Kargl <sgk@troutmask.apl.washington.edu> To: Stephen Montgomery-Smith <stephen@missouri.edu> Cc: Diane Bruce <db@db.net>, John Baldwin <jhb@freebsd.org>, David Chisnall <theraven@freebsd.org>, Bruce Evans <bde@freebsd.org>, Bruce Evans <brde@optusnet.com.au>, David Schultz <das@freebsd.org>, Peter Jeremy <peter@rulingia.com>, Warner Losh <imp@bsdimp.com> Subject: Re: Use of C99 extra long double math functions after r236148 Message-ID: <20120718205625.GA409@troutmask.apl.washington.edu> Resent-Message-ID: <20120812230727.GA20453@server.rulingia.com> In-Reply-To: <5006D13D.2080702@missouri.edu> References: <201207130818.38535.jhb@freebsd.org> <9EB2DA4F-19D7-4BA5-8811-D9451CB1D907@theravensnest.org> <C527B388-3537-406F-BA6D-2FA45B9EAA3B@FreeBSD.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>
next in thread | previous in thread | raw e-mail | index | archive | help
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. -- Steve
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120718205625.GA409>