binary-ieee754-0.1.0.0: Backport ieee754 float double combinators to older binary
Safe HaskellTrustworthy
LanguageHaskell2010

Data.Binary.IEEE754

Description

This module backports ieee754 double/float combinators from binary 0.8.4 to older version, and simply re-export these combinators for binary >= 0.8.4. You can safely import this module alongside Data.Binary.Get and Data.Binary.Put.

Implements casting via a 1-elemnt STUArray, as described in http://stackoverflow.com/a/7002812/263061.

Synopsis

Double/Float Word cast

floatToWord :: Float -> Word32 Source #

Reinterpret-casts a Float to a Word32.

wordToFloat :: Word32 -> Float Source #

Reinterpret-casts a Word32 to a Float.

doubleToWord :: Double -> Word64 Source #

Reinterpret-casts a Double to a Word64.

wordToDouble :: Word64 -> Double Source #

Reinterpret-casts a Word64 to a Double.

Double/Floats Get

getFloatbe :: Get Float #

Read a Float in big endian IEEE-754 format.

getFloatle :: Get Float #

Read a Float in little endian IEEE-754 format.

getFloathost :: Get Float #

Read a Float in IEEE-754 format and host endian.

getDoublebe :: Get Double #

Read a Double in big endian IEEE-754 format.

getDoublele :: Get Double #

Read a Double in little endian IEEE-754 format.

getDoublehost :: Get Double #

Read a Double in IEEE-754 format and host endian.

Double/Floats Put

putFloatbe :: Float -> Put #

Write a Float in big endian IEEE-754 format.

putFloatle :: Float -> Put #

Write a Float in little endian IEEE-754 format.

putFloathost :: Float -> Put #

Write a Float in native in IEEE-754 format and host endian.

putDoublebe :: Double -> Put #

Write a Double in big endian IEEE-754 format.

putDoublele :: Double -> Put #

Write a Double in little endian IEEE-754 format.

putDoublehost :: Double -> Put #

Write a Double in native in IEEE-754 format and host endian.