[Haskell-cafe] implementing RealFloat decodeFloat

Henning Thielemann lemming at henning-thielemann.de
Fri Jan 7 00:09:30 CET 2011


Claude Heiland-Allen schrieb:

> I've been working on [0] Haskell bindings for [1] libqd for [2]
> double-double and quad-double arithmetic,

At the ICIAM conference in Zurich 2007 I heard about the sum algorithm
with two double precision floating point numbers in three talks. :-)
Nice to know that those ideas can be found in a library.

> The double-double and quad-double types do not have a fixed precision,
> though they do have a fixed minimum precision: this means that
> decodeFloat will (in general) lose some precision.  This is because for
> example in:
> 
>   data DoubleDouble = DoubleDouble !CDouble !CDouble
>   dd = DoubleDouble a b
> 
> the semantics are that "dd = a + b", with |a|>>|b|; coupled with the
> IEEE implicit leading 1 bit, this means that there may be large gaps
> between exponents: for example: "1 + 0.5**100 :: DoubleDouble".

They are possible, but do they really occur? I thought the intention of
using two CDoubles is to double the precision, not more. I can hardly
imagine that its algorithms makes use of numbers like (1 + 0.5**100).
Does the library specify something about maximum precision?

I would just represent (1 + 0.5**100) as largeInteger*2^-largeExponent.
You can represent all such numbers without loss of precision, but with
loss of memory. :-)




More information about the Haskell-Cafe mailing list