Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| Newsgroups | comp.arch |
|---|---|
| Date | 2016-01-28 14:49 -0800 |
| References | <0eb97c14-d5ac-4e93-b063-1d1eba7831e1@googlegroups.com> <n831ib$505$1@dont-email.me> <0a991790-09f0-490f-897a-d138176da966@googlegroups.com> <960d8ecf-d251-40fc-993a-78fb8b3d25ba@googlegroups.com> <n8ds2n$1iq$1@gioia.aioe.org> |
| Message-ID | <39db337e-e09f-4d69-a860-53a26788788f@googlegroups.com> (permalink) |
| Subject | Re: NR reciprocal/division without extended precision |
| From | already5chosen@yahoo.com |
On Thursday, January 28, 2016 at 10:01:33 PM UTC+2, Terje Mathisen wrote: > already5chosen@yahoo.com wrote: > > On Sunday, January 24, 2016 at 7:46:12 PM UTC+2, MitchAlsup wrote: > >> On Sunday, January 24, 2016 at 11:30:29 AM UTC-6, James Van Buskirk > >> wrote: > >> > >>> There seems to be some sort of theorem that you need 2*n+1 bits > >>> of accuracy to get to n bit rounded perfectly. > >> > >> Its either 2n+2 or 2n+3 depending upon certain setups of the > >> iteration algorithm. And indeed Peter Markstein is the right > >> literature reference. > > > > First, let's agree on terminology: n bits of matissa + 1 hidden bit > > are considered n+1 bits. IEEE-754 binary64 = 53 bit. > > The IEEE double has a n==52-bit mantissa. :-) > Yes, 52 bits stored, but 53 bits significant. But then I managed to fool myself with all +1s and -1s. What I meant to say that for proper rounding of the worst case of IEEE-754 binary64 we need to take into account 107 significant bits. Which makes it 2n+1 rather than 2n+3 :( > Otherwise there wouldn't be room for an 11-bit exponent and a sign bit. > > > > According to my math, y = 1-2^(-n-1) is the only argument in range > > [0.5..1) that requires 2n+3 bits for convergence. y = 1-3*2^(-n-1) is > > another argument that can ask for 2n+2 bits, but only in unusual > > rounding modes. In the default 'round to nearest even' mode it will > > converge to correct value with 2n+1 bits. It looks like 2n+1 bits are > > sufficient for the rest of the arguments in all rounding modes. > > So what you are saying is that it might be worth it to recognize an > all-1 mantissa and specialcase it in order to avoid the need for two > extra bits of intermediate precision? I think, the best practical solution would be to generate an exact result for this bit pattern as an initial approximation. With table-driven initial approximation it will be really easy. For example, 16-entry table addressed by 4 MS bit of mantissa: 0 => 32/sqrt(16*17), // [16/32..17/32) 1 => 32/sqrt(17*18), // [17/32..18/32) 2 => 32/sqrt(18*19), // [18/32..19/32) ... 14 =>32/sqrt(30*31), // [30/32..31/32) 15 =>1-2^-53, // [31/32..1) Pay attention that the worst case relative error in "asymmetric" last range is approximately the same as in symmetric first range, so # of required NR steps is not impacted by the trick. > > Terje > > -- > - <Terje.Mathisen at tmsw.no> > "almost all programming can be viewed as an exercise in caching"
Back to comp.arch | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
NR reciprocal/division without extended precision already5chosen@yahoo.com - 2016-01-24 08:36 -0800
Re: NR reciprocal/division without extended precision "James Van Buskirk" <not_valid@comcast.net> - 2016-01-24 10:29 -0700
Re: NR reciprocal/division without extended precision MitchAlsup <MitchAlsup@aol.com> - 2016-01-24 09:46 -0800
Re: NR reciprocal/division without extended precision already5chosen@yahoo.com - 2016-01-28 01:16 -0800
Re: NR reciprocal/division without extended precision Terje Mathisen <terje.mathisen@tmsw.no> - 2016-01-28 21:01 +0100
Re: NR reciprocal/division without extended precision already5chosen@yahoo.com - 2016-01-28 14:49 -0800
Re: NR reciprocal/division without extended precision Terje Mathisen <terje.mathisen@tmsw.no> - 2016-01-29 07:38 +0100
csiph-web