On Sun, Feb 24, 2008 at 12:21:00PM +0000, Paul Johnson wrote:
> I'm working on an implementation of the framing layer for AMQP 
> (www.amqp.org).  I almost had 0.9 finished when I found they had released 
> the spec for 0.10, so I have to redo quite a lot of work.
>
> Amongst the new features of 0.10 are wire formats for floating point.  
> These are the 4 and 8 byte IEEE formats.
>
> * Is there a principled way of converting a Haskell Float or Double (or 
> Rational, for that matter) to and from IEEE format?
>
> * Since many computers use IEEE format natively, is there a quicker way of 
> doing this on those architectures?

{-# LANGUAGE MagicHash #-}
import Data.Int
import GHC.Exts

foo :: Double -> Int64 --ghc only
foo (D# x) = I64# (unsafeCoerce# x)

Stefan

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to