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



From: "Dinh Tien Tuan Anh" <[EMAIL PROTECTED]>
To: haskell-cafe@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@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/

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to