-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Parser/Serializer for IEEE-754 floating-point values -- -- Convert Float and Decimal values to/from raw octets. @package data-binary-ieee754 @version 0.2 module Data.Binary.IEEE754 -- | Parse a big-endian byte list into a floating-point value. parseFloatBE :: (RealFloat a) => [Word8] -> a -- | Parse a little-endian byte list into a floating-point value. parseFloatLE :: (RealFloat a) => [Word8] -> a getFloat16be :: Get Float getFloat16le :: Get Float getFloat32be :: Get Float getFloat32le :: Get Float getFloat64be :: Get Double getFloat64le :: Get Double -- | Parse a floating-point value of the given width (in bytes) from within -- a Get monad. getFloat :: (RealFloat a) => ByteCount -> ([Word8] -> a) -> Get a putFloat32be :: (RealFloat a) => a -> Put putFloat32le :: (RealFloat a) => a -> Put putFloat64be :: (RealFloat a) => a -> Put putFloat64le :: (RealFloat a) => a -> Put putFloat :: (RealFloat a) => ByteCount -> (ByteCount -> Integer -> [Word8]) -> a -> Put -- | Calculate the proper size of the exponent field, in bits, given the -- size of the full structure. exponentWidth :: BitCount -> BitCount -- | Considering a byte list as a sequence of bits, slice it from start -- inclusive to end exclusive, and return the resulting bit sequence as -- an integer bitSlice :: [Word8] -> BitCount -> BitCount -> Integer -- | Split a raw bit array into (sign, exponent, fraction) components. -- These components have not been processed (unbiased, added significant -- bit, etc). splitRawIEEE754 :: [Word8] -> (Bool, Exponent, Fraction) -- | Unbias an exponent unbias :: Exponent -> BitCount -> Exponent -- | Parse values into a form suitable for encodeFloat sign exponent -- fraction width-in-bits -> fraction, exponent mergeFloat :: Exponent -> Fraction -> BitCount -> (Integer, Int) bias :: (Integral a, Integral b) => a -> b -> a -- | Encode an integer to a list of words, in big-endian format encodeIntBE :: ByteCount -> Integer -> [Word8] -- | Encode an integer to a list of words, in little-endian format encodeIntLE :: ByteCount -> Integer -> [Word8] floatToMerged :: (RealFloat a) => ByteCount -> a -> Integer mergeFloatBits :: BitCount -> BitCount -> Bool -> Fraction -> Exponent -> Integer floatComponents :: (RealFloat a) => ByteCount -> a -> (Bool, Fraction, Exponent) -- | Base-2 log of an integer -- -- Integral exponent type Exponent = Int type Fraction = Integer type BitCount = Int