realToFrac issues

Simon Marlow simonmar at
Wed Mar 1 07:46:38 EST 2006

On 28 February 2006 18:42, Jacques Carette wrote:

> What *problem* are you actually trying to solve here?

The problem that 'realToFrac (0/0 :: Float) :: Double' doesn't give you
NaN, and similarly for the other special float values.

> If it is
> "conversion between floating point types", then there are other
> solutions that do not need to ``pollute'' exact arithmetic.  I did not
> see any tickets on this -- did I miss it/them?  This is one issue
> where I should go and contribute, as I've been part of a team that
> has done just this to a programming language before, so at least I
> can claim to know the pitfalls to avoid!

Please go ahead and create a ticket.  

I don't claim to know a great deal about floating point, but Cale
Gibbard's suggestion (use encodeFloat.decodeFloat) looks reasonable to
me.  I have an old item on my GHC ToDo list that says "make
encodeFloat.decodeFloat work for NaN" :-)


More information about the Haskell-prime mailing list