
11 Dec
2009
11 Dec
'09
2:14 a.m.
I've been trying to play around with binary data, but I haven't made much progress trying to print the bits of a Double. With help from #haskell I've made it this far: -- Printing the bits of an Int main = do putStrLn $ showIntAtBase 2 (chr . (48+)) z "" -- 103 = 1100111, after bit shifting 11001 z = shiftR (103 :: Int64) 2 This is as far as I got with Doubles: import Data.Binary.IEEE754 import qualified Data.ByteString.Lazy as BS main = do BS.putStrLn $ runPut $ putFloat64be 4.123 Instead of playing with ByteStrings, is there just a way to fill an Int64 with the bits of a Double (Similar to Java's long = Double.doubleToLongBits(double))?