On Thu, 28 Oct 2004, Hal Fulton wrote:

> David G. Andersen wrote:
> 
> > The problem in this case isn't actually in the storage
> > of 9.95 or 995 in floating point;  it comes in when you do the
> > multiplication.
> 
> I'm not sure it's *just* in the multiplication... 0.95 can't
> be stored exactly in binary, can it?
> 

     It can, but not using only a (binary) mantisa & (binary) exponent.  
You could, for example, use offset decimal exponents (so incrementing the 
exponent by 1 effectively multiplies the result by ten instead of two), or 
by storing them as a numerator and denomonator (e.g. Rational).  Or you 
could cheat and use BCD.

     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.

      -- Markus