[Haskell-cafe] Data.Binary suboptimal instance

Tim Docker twd2 at dockerz.net
Sun May 24 19:49:26 EDT 2009


andrewcoppin:
> The problem seems to boil down to this: The Binary instance for
> Double (and Float, by the way) is... well I guess you could argue
> it's very portable, but efficient it isn't. As we all know, an
> IEEE-754 double-precision floating-point number occupies 64 bits;
> 1 sign bit, 11 exponent bits, and 52 mantissa bits (implicitly 53).
> I had assumed that the Binary instance for Double would simply write
> these bits to disk, requiring approximately 0 computational power, and
> exactly 64 bits of disk space. I was wrong.
>
> Is there any danger that there might be some kind of improvement to the
> Double instance in the next version of Data.Binary?

This was discussed last week. A patch was posted implementing more
efficient low level double encodings. Google for the thread: "Data.Binary
and little endian encoding".

Tim






More information about the Haskell-Cafe mailing list