Chris Kuklewicz wrote:
I am cross-posting this message to several lists.
I had learned the trick before the documentation was updated. It seems
I have used a very unreliable trick. And the "use castToSTUArray"
suggested alternative is a really poor one since I am not using arrays
at all.
castSTUArray is the way GHC does it - the idea is to allocate a small
array, store the Float/Double in it, cast the type of the array to
Word32 or whatever, and then read out the contents.
It's more or less equivalent to the peek/poke solution, except that it
doesn't need unsafePerformIO.
GHC's code is here: (look for floatToWord):
http://darcs.haskell.org/ghc/compiler/cmm/PprC.hs
Cheers,
Simon
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe