简体   繁体   English

双双精度浮点数作为两个双精度数之和

[英]double-double precision floating point as sum of two doubles

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.关注双双算术的论文和源代码一段时间后,我仍然无法弄清楚 dd_real (定义为struct dd_real { double x[2];...} )数字究竟是如何分成两个双打的。 Say if I initialize it with a string, dd_real pi = "3.14159265358979323846264338327950";假设我用字符串初始化它, dd_real pi = "3.14159265358979323846264338327950"; what will be pi.x[0] and pi.xi[1] ? pi.x[0]pi.xi[1]什么? I need to understand it and then write a hopefully small Python function that does it.我需要理解它,然后编写一个希望很小的 Python 函数来完成它。

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.我不只是想调用 QD 库的原因是我更喜欢在 Python 中重新实现正确的拆分,以便我将我的 35 位精度常量(以字符串形式给出)作为double2发送到 CUDA 代码,它会被GQD 库视为双精度实数——似乎是唯一一个处理 CUDA 中扩展精度计算的库。 That unfortunately rules out mpmath too, on Python side.不幸的是,在 Python 方面,这也排除了 mpmath。

Say that you initialize your double double with the binary number:假设您使用二进制数初始化double double

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

Then one double will be 1.0110101011111110101010101010100000001010101101100001 and the other will be 1.1011111101010010101010 * 2^-53然后一个double将是1.0110101011111110101010101010100000001010101101100001另一个将是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.第一个在其 52 位尾数中包含尽可能多的位。 The second one contains the remaining bits, with the appropriate exponent.第二个包含剩余的位,具有适当的指数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM