Last update: Nov. 8, 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:

- (approximate) the four arithmetic operations
- (approximate) the sqrt function
- equality and inequality
- abs, floor, and frexp
- mathematical functions, e.g., exp, log, sin, cos, tan, sinh, cosh, tanh, asin, acos, atan, asinh, acosh, atanh, expm1, log1p, and pow
- the interconversion between dd-type numbers and decimal-number characters

Moreover, this library is able to perform the interval arithmetic with the double-double precision
with the following functions in rdd.hpp:
- the four arithmetic operations with changing a rounding mode
- the sqrt operation with changing a rounding mode
- the interconversion between dd's and characters with specifying a rounding mode

##
2. Files

dd.hpp

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

rdd.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)
.
##
6. Compile Option

It may be possible to speed up with the compile option,
see
20. Changing Rounding Mode and Compile Options
for details.
##
7. Problem of 32bit mode of Intel's CPU

Intel's CPUs has the following two floating point units:
- the traditional FPU;
- SSE2 in recent CPUs.

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.