[Haskell-cafe] ANN: convertible (first release)
Daniel Schüssler
anotheraddress at gmx.de
Tue Feb 10 02:46:31 EST 2009
Hi,
On Wednesday 28 January 2009 04:30:07 John Goerzen wrote:
> On Tue, Jan 27, 2009 at 09:41:30PM -0500, wren ng thornton wrote:
> > I once again point out that realToFrac is *wrong* for converting from
> > Float or Double.
> >
> > > realToFrac (1/0::Float) ::Double
> >
> > 3.402823669209385e38
>
> Yes, I understand what you are saying and agree with you. But there
> is nothing better in the standard library
don't know whether you consider GHC as standard library, but if you do...:
import GHC.Types
import GHC.Prim
-- | Double to Float
d2f (D# d) = F# (double2Float# d)
-- | Float to Double
f2d (F# f) = D# (float2Double# f)
ghci> f2d (1/0)
Infinity
it :: Double
:)
--
Daniel
More information about the Haskell-Cafe
mailing list