[Haskell-cafe] question about Data.Binary and Double instance

Stefan O'Rear stefanor at cox.net
Sun Apr 22 17:52:19 EDT 2007


On Sun, Apr 22, 2007 at 10:43:23PM +0100, Ian Lynagh wrote:
> On Tue, Apr 17, 2007 at 11:42:40PM -0400, Brian Alliet wrote:
> > 
> > > Perhaps we just don't care about ARM or other arches where GHC runs that
> > 
> > Are there really any architectures supported by GHC that don't use IEEE
> > floating point? If so GHC.Float is wrong as isIEEE is always true.
> 
> The one most likely to be non-IEEE is ARM, which has a middle-endian
> representation; to make it explicit, it's the middle case here
> (FLOAT_WORDS_BIGENDIAN but not WORDS_BIGENDIAN):
> 
> #if WORDS_BIGENDIAN
>     unsigned int negative:1;
>     unsigned int exponent:11;
>     unsigned int mantissa0:20;
>     unsigned int mantissa1:32;
> #else
> #if FLOAT_WORDS_BIGENDIAN
>     unsigned int mantissa0:20;
>     unsigned int exponent:11;
>     unsigned int negative:1;
>     unsigned int mantissa1:32;
> #else
>     unsigned int mantissa1:32;
>     unsigned int mantissa0:20;
>     unsigned int exponent:11;
>     unsigned int negative:1;
> #endif
> #endif
> 
> Does anyone know if that makes it non-IEEE?

AIUI, ieee754 talks about high bits and low bits, not first or last
bytes, which means that it is endianness independant.  this also means
that ieee754 values are endian dependant - we'll have to swap them
into network byte order before saving, if we're on a le host. 

Stefan


More information about the Haskell-Cafe mailing list