[Haskell-cafe] Error with Float

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


Opps, its 0:f t
         not 0:: f t
and the same for 1:f (t-1)



>From: "Dinh Tien Tuan Anh" <tuananhbirm at hotmail.com>
>To: haskell-cafe at haskell.org
>Subject: [Haskell-cafe] Error with Float
>Date: Tue, 19 Jul 2005 14:48:55 +0000
>
>
>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!  
>http://toolbar.msn.co.uk/
>
>_______________________________________________
>Haskell-Cafe mailing list
>Haskell-Cafe at haskell.org
>http://www.haskell.org/mailman/listinfo/haskell-cafe

_________________________________________________________________
Want to block unwanted pop-ups? Download the free MSN Toolbar now!  
http://toolbar.msn.co.uk/



More information about the Haskell-Cafe mailing list