cereal-ieee754-0.1: Floating point support for the 'cereal' serialization library

Data.Serialize.IEEE754

Contents

Description

Functions for reading, writing and converting IEEE 754 floating point numbers.

Conversions use STUArray and the ST monad to reinterpret bytes and get what we assume to be the IEEE 754 binary representation of single and double precision floating point numbers.

Synopsis

Big-endian reads

getFloat32be :: Get FloatSource

Read a 32-bit float in big endian format

getFloat64be :: Get DoubleSource

Read a 64-bit float in big endian format

Little-endian reads

getFloat32le :: Get FloatSource

Read a 32-bit float in little endian format

getFloat64le :: Get DoubleSource

Read a 64-bit float in little endian format

Host-endian, unaligned reads

getFloat32host :: Get FloatSource

Read a 32-bit float in native host order and host endianness

getFloat64host :: Get DoubleSource

Read a 64-bit float in native host order and host endianness

Little-endian writes

putFloat32le :: Putter FloatSource

Write a 32-bit float in little endian format

putFloat64le :: Putter DoubleSource

Write a 64-bit float in little endian format

Big-endian writes

putFloat32be :: Putter FloatSource

Write a 32-bit float in big endian format

putFloat64be :: Putter DoubleSource

Write a 64-bit float in big endian format

Host-endian, unaligned writes

putFloat32host :: Putter FloatSource

Write a 32-bit float in native host order and host endianness

putFloat64host :: Putter DoubleSource

Write a 64-bit float in native host order and host endianness

Conversions

floatToWord :: Float -> Word32Source

Interpret a 32-bit float as a 32-bit word.

wordToFloat :: Word32 -> FloatSource

Interpret a 32-bit word as a 32-bit float.

doubleToWord :: Double -> Word64Source

Interpret a 64-bit float as a 64-bit word.

wordToDouble :: Word64 -> DoubleSource

Interpret a 64-bit word as a 64-bit float.