From: "trans. (T. Onoma)" Date: 2004-10-29T15:52:45+09:00 Subject: Re: Rounding error, (100.0 * 9.95).to_i == 994 On Thursday 28 October 2004 12:13 pm, Markus wrote: | On Wed, 2004-10-27 at 17:40, trans. (T. Onoma) wrote: | > On Wednesday 27 October 2004 08:22 pm, markus@reality.com wrote: | > | My favorite trick is storing a "repeat length" that works like the | > | bar you use when dealing with repeated decimals on paper. I once saw a | > | very clever description of how to make that work. But (so far as I | > | know), no FPU designers read the same paper. | > | > That was I was thinking. Do you know where your read it? | | No. I think it was an ACM or IEEE paper from the early eighties. | But I can't even swear to that. The basic idea was that: | | 1. You don't have to worry about repeat lengths greater than your | mantissa length | 2. Repeats automatically "end align" | 3. Non-repeating decimals can be thought of as having a repeat | length of one on the terminal bit | 4. Repeats combine with an LCM rule, which can be computed in | hardware comparable in complexity to the exponent logic or | stored if you accept some limitations | 5. Detecting reductions in repeat length could be done by using | some sort of shift xor thing that was described (IIRC) as being | simple but seemed complex to me | 6. It doesn't matter if it ever get implemented as long as the | author can add the paper about how it could be done to his | publications list No doubt, there are some difficulties, but it certainly seems completely doable. And #6 sounds about right! Leave it to human beings to go on and on bitching and dealing with rounding issues and what not, rather then taking stock and fixing the problem. But maybe there are alternative reasons for it. Wasn't it Richard Pryor in Superman 4 that got rich off this bug? :) T.