1998 February 03

The doubledouble homepage


Overview

This page describes my C++ software package `doubledouble' which implements approximately 30 decimal place floating point arithmetic. This code does NOT use multiple-precision or arbitrary-precision methods, which always have a significant speed penalty. Rather, the intention is to increase precision beyond double, while maintaining efficiency. The speed penalty is about a 10-25 times slowdown compared to double precision. Hardware strictly conforming to IEEE 754 is essential, though the Pentium is also acceptable since the control word is manipulated to override the effect of double rounding.

This is the probably the simplest way to increase the precision of existing double-precision C or C++ code. For a quick conversion of simple programs, all that may be required to convert to doubledouble is the addition of two lines:

#include "doubledouble.h"
#define double doubledouble

and the linking of the doubledouble library.
(This is NOT the recommended method, though. See the file trydd.cc for more sophisticated examples of usage.)


Internals

The techniques used are the well-known ones due to Dekker, Linnainmaa, Kahan, Knuth and Priest; that is, the same methods normally used for software implementations of real*16 in Fortran compilers. I credit Kahan with the addition algorithm (the simplification which permits the elimination of the tests and branches is due to Knuth); Dekker and Linnainmaa with the multiply, divide, and square root routines, and Priest for an initial transcription into C++.

Included is a fairly complete math library, which borrows some ideas from David Bailey's MPFUN fortran package.

Except where otherwise indicated by comments in the code, this software is covered by the GNU Public License, as described in the included COPYLEFT notice.

The current version is 2.2. This version includes many improvements suggested by Stefan Bauberger, Roger Schlafly, Wayne Hayes, Victor Shoup, Tony Dixon, and Alan Miller. These include new operators, more transcendental functions, portability enhancements, and improvements to many details. In particular, I am grateful to Wayne Hayes for writing new output formatting code, more overloaded operators, modf, and a new test program. Victor Shoup supplied a fix for the non-IEEE Pentium problem.

Warning: the representable numbers in this system have a strange distribution. For example, numbers like 1+1e-300 can be represented. This makes the concept of machine epsilon rather ambiguous. For more information on the theory, see this paper by Kahan.

This is a development of code formerly released as `Quad version 2.0'. The name Quad has been dropped as the code does NOT implement the IEEE quadruple precision format. The name `doubledouble' was chosen instead since it is distinctive and reminds one that an unusual data type is being used, and it describes the format of two adjacent doubles.

The code was developed with g++ 2.7.2.1 and egcs-1.0 (See egcs project home page or UK mirror).
To use doubledouble precision complex numbers,
#include <std/complext.h>
#include <std/complext.cc>
typedef complex<doubledouble> dd_complex;

The code has been tested on:
x86-unknown-linux with gcc 2.7.2.1
mips*-sgi-irix6 with ecgs-1.0
sparc-sun-solaris2.4 with ecgs-1.0
x86-unknown-windows95 with Microsoft C++ 5.0.


Applications

This code has been used for:

Studies of Feigenbaum scaling in discrete dynamical systems.
Two-loop integral for radiative corrections in muon decay.
Number theory research, e.g. in LLL algorithms.
Coefficient generation and checking of double-precision algorithms for transcendental functions.
Testing sensitivity to rounding errors of existing double-precision code.

An earlier version of this code is also used in the C++ libraries LiDIA (as xdouble) and NTL (as quad_float).
These libraries also implement arbitrary-precision arithmetic.


Download the current version

as a gzipped tar file: shift-click here
as a shar file: click here

The sources (not necessarily the current version) may be browsed here:
doubledouble.h
doubledouble.cc
inline.h
math.cc


Installation

0. Unpack shar or tar file. Typical location: ~/math++/2.2/
1. Edit top part of `Makefile' to suit your hardware and compiler
2. make
User programs should:
(a) #include "doubledouble.h"
(b) compile with -DDD_INLINE
(c) compile with -Dx86 on x86 hardware (including Pentium)
(d) link libdoubledouble.a
See trydd.cc for examples of usage.

Screenshot


Bugs

There is not much documentation apart from this webpage.
Feedback is very welcome, especially reports of success or failure on other platforms.

Please send reports to Keith Briggs, not forgetting to clean up the processed meat first.

Department of Plant Sciences, University of Cambridge, Downing Street, Cambridge CB2 3EA.