I found one way: doubleToInts d = runST ( do arr <- newDoubleArray (1,2) writeDoubleArray arr 1 d i1 <- readIntArray arr 1 i2 <- readIntArray arr 2 return (i1,i2))
intsToDouble (i1,i2) = runST ( do arr <- newDoubleArray (1,2) writeIntArray arr 1 i1 writeIntArray arr 2 i2 readDoubleArray arr 1) But this is dumb and very slow (also note that the array has to be indexed to 2 even though it's only storing one double; this is because readIntArray checks the double bounds). Ideas *other* than this are still welcome :) -- Hal Daume III "Computer science is no more about computers | [EMAIL PROTECTED] than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume On Wed, 3 Apr 2002, Hal Daume III wrote: > I'm looking for a (not-necessarily Haskell 98 compliant, as long as it > works in GHC) way to get at the internal representation of Doubles. I can > use decodeDouble# to get at it, but I need something equivalent to > encodeDouble# to go the other way, and I cannot find such a function > anywhere. Any suggestions are welcome (yes, I know I can use show and > read, but I'm looking for something which will keep the # of bytes down). > > - Hal > > -- > Hal Daume III > > "Computer science is no more about computers | [EMAIL PROTECTED] > than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume > > _______________________________________________ > Haskell mailing list > [EMAIL PROTECTED] > http://www.haskell.org/mailman/listinfo/haskell > _______________________________________________ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell