Last update: May 15, 2017

Library for arithmetics with double-double precision

Masahide Kashiwagi

1. Introduction

This library provides a computation with the double-double precision (corresponding to the quadruple precision) using Knuth's twosum algorithm and Dekker's twoproduct algorithm, as the software provided by David H. Bailey in High-Precision Software Directory .

This library (dd.hpp) has:

Moreover, this library is able to perform the interval arithmetic with the double-double precision with the following functions in rdd.hpp:

2. Files

(requiring conv-dd.hpp, fpu53.hpp, convert.hpp, and constants.hpp)
(requiring hwround.hpp, rdd-hwround.hpp, and rdd-nohwround.hpp)

3. How to use

See test-dd.hpp for the dd arithmetic. See test-idd.hpp for the interval arithmetic with the dd precision.

4. Algorithm

See section 1-4 in double-double arithmeric and double-double interval arithmeric (Version 2017/5/12, in Japanese) . Or see simple memos.

5. Interval arithmetic with dd precision

The interval arithmetic with the dd precision is performed by changing a rounding mode accurately. See section 5 in double-double arithmeric and double-double interval arithmeric (Version 2017/5/12, in Japanese) .

(Added on Apr. 9, 2014) By compiling a program with the option -DKV_NOHWROUND, a computation can be done without any actual changes of rounding modes; all changes of rounding modes are emulated.

6. Using FMA

(Added on Apr. 29, 2017) By compiling a program with the option -DKV_USE_TPFMA, the twoproduct will be executed using FMA. The option seems to be usable for CPUs after Haswell and OS/compiler which are not so old. The usability of the option can be checked by the following procedure:

7. Problem of 32bit mode of Intel's CPU

Intel's CPUs has the following two floating point units:

The computational precision in FPU is 80bit (total) and 64bit (significand), which is different from the IEEE754 standard of 64bit (total) and 53bit (significand). This causes deviance in dd-precision arithmetics.

On the other hand, SSE2 conforms the IEEE754 standard and Intel's CPUs in the 64bit mode employs not FPU but SSE2. Therefore, in the 64bit mode, such deviance does not occur. Even in the use of 32bit CPUs, "-msse2 -mfpmath=sse" provides a safe computation.

Fortunately, in the FPU Control Register, there is the flag that specifies a computational precision. If one can change this flag from 64bit to 53bit, the deviance due to FPU is prevented. Although this can be done with including fpu53.h in this library, some compiler may not support this change.

8. Others

(Added on Nov. 12, 2014) We implemented a mathematical function (approximation) when using dd.hpp alone. Verified mathematical functions for interval<dd> can be used originally.

stringtodd, ddtostring contained in conv-dd.hpp performs mutual conversion between dd type and decimal character string. Since conv-dd.hpp can be used alone, if you are troubled with dd input/output, please use it.