[Haskell-cafe] question about Data.Binary and Double instance

David Roundy droundy at darcs.net
Tue Apr 17 15:18:29 EDT 2007

On Tue, Apr 17, 2007 at 02:50:14PM -0400, Brian Alliet wrote:
> I threw together a somewhat portable "longBitsToDouble" function a
> while ago for another project.
> http://darcs.brianweb.net/hsutils/src/Brianweb/Data/Float.lhs
> It doesn't depend on any unsafe operations or external ffi functions
> but it will only works on IEEE 754 machines (but that includes every
> machine ghc run on). It might not be fast enough for you though as it
> still goes via Integer in the conversion.

It seems like this conversion shouldn't take any time at all, and we ought
to be able to just copy the memory right over, or just do a unsafeCoerce#
(which is admittedly unsafe, but in practice between a Word64 and a Double
should be fine)...
David Roundy
Department of Physics
Oregon State University

More information about the Haskell-Cafe mailing list