Machine bit representations

Matt Harden matth@mindspring.com
Tue, 24 Jul 2001 22:35:58 -0500


pachinko@magicaldesk.com wrote:
> 
> Hello,
> 
> Is it possible in Haskell to access the underlying machine bit representation of a Float or Double value?
> 
> I need to be able to be able to send this bit representation as a list of bytes in network byte order to a process running on a different platform (with a different host byte order to my platform).
> 
> For reference, I run Haskell under Linux on Intel. The processes I want to communicate with run under Sun Solaris, Hitachi HPUX and Java everywhere.
> 
> Any suggestions, for any Haskell translator much appreciated.
> 
> Thanks.

Look at encodeFloat and decodeFloat, documented in section 6.4.6 of The
Haskell 98 Report.  They offer "efficient, machine-independent access to
the components of a floating-point number".

See http://www.haskell.org/onlinereport/basic.html#sect6.4.6

Matt Harden