Re: More atom precision (was: Re: File size limit)
- Posted by Fernando Bauer <fmbauer at hotma?l.?om> Jun 12, 2008
- 717 views
Jason Gade wrote: > > Jason Gade wrote: > > > > Okay, I looked at the code again and I think that I got it right. > > > > First let me say that the epsilon and exponent stuff was actually written by > > Matt Lewis. I just "adopted" (stole) it. > > > > What I realized reading the code, though, was that it wasn't a comparison to > > -1023 that should be changed (which made little sense to me) but rather > > this: > > > > }}} <eucode> > > if exp > 1023 then > > -- normalized, so implicit 1 (53rd bit) in front > > epsilon = power(2, exp - 53) > > else > > -- denormalized, so no implicit 1 (no 53rd bit) > > epsilon = power(2, exp - 52) > > end if > > </eucode> {{{ > > > > The original code compared to 52 and 51 respectively. An off by one error. A > > normalized number adds an implicit 53rd bit (and therefore an extra power of > > 2) and a denormalized number only uses the 52 bits of the fraction to > > represent > > the number. > > > > I could be wrong, but that was my thought process, and it seems to be > > consistent > > at the high end. > > > > I haven't tested it at the small end. > > Never mind -- I think I see comparing to -1023 more clearly and more correct. > > Thanks again, my understanding of FP representation has increased. > Thanks Jason for our chat about this subject. As you, I think my understanding of Euphoria and FP representation have increased too. Best Regards, Fernando