[Haskell-cafe] Error with Float

Dinh Tien Tuan Anh tuananhbirm at hotmail.com
Tue Jul 19 10:48:55 EDT 2005

This is my function to convert a fraction (0<x<1) to binary :

   f x
      ¦t<1        = 0::f t
      ¦otherwise = 1::f (t-1)
      where t = 2*x

I guess there's nothing wrong with that, but when traced, it has something 
like 0.6*2 - 1 = 0.600001
This error got accumulated and made my f function wrong (will eventually 
evaluate an infinite 0, no matter what value of x)

Please tell me there's some ways to deal with that.

Thanks a lot

Want to block unwanted pop-ups? Download the free MSN Toolbar now!  

More information about the Haskell-Cafe mailing list