double-double precision floating point as sum of two doubles
Asked Answered
T

1

4

Following papers and source code for double-double arithmetic for some time, I still can't find out how exactly a dd_real ( defined as struct dd_real { double x[2];...}) number is split into two doubles. Say if I initialize it with a string, dd_real pi = "3.14159265358979323846264338327950"; what will be pi.x[0] and pi.xi[1]? I need to understand it and then write a hopefully small Python function that does it.

The reason I don't just want to call into the QD library is that I'd prefer to reimplement the correct split in Python so that I send my 35-digit precision constants (given as strings) as double2 to CUDA code where it will be treated as double-double reals by the GQD library -- the only library, it seems, to deal with extended precision calculations in CUDA. That unfortunately rules out mpmath too, on Python side.

Trossachs answered 25/3, 2012 at 2:20 Comment(2)
It would be easier if you took an example in binary or in hexadecimal. Even if someone literally answers your question (by telling you the values of pi.x[0] and pi.x[1]), you won't be able to make any sense of the split with respect to the original decimal value.Granulation
Also note that double double is in no way "arbitrary precision". It is only "more precision that IEEE 754 double precision, while taking advantage of the available double precision hardware".Granulation
G
7

Say that you initialize your double double with the binary number:

1.011010101111111010101010101010000000101010110110000111011111101010010101010
  < ---                 52 binary digits         --- >< --- more digits --- >

Then one double will be 1.0110101011111110101010101010100000001010101101100001 and the other will be 1.1011111101010010101010 * 2^-53

When you add these two numbers (as reals), the sum is the initial value. The first one packs as many bits as possible in its 52-bit mantissa. The second one contains the remaining bits, with the appropriate exponent.

Granulation answered 25/3, 2012 at 3:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.