xprec - fast emulated quadruple (double-double) precision in rust
=================================================================
Emulates quadruple precision with a pair of doubles. This roughly doubles
the mantissa bits (and thus squares the precision of double). The range
is almost the same as double, with a larger area of denormalized numbers.
This is also called double-double arithmetic, compensated arithmetic, or Dekker
arithmetic.
The rough cost in floating point operations (flops) and relative error as
multiples of u² = 1.32e-32 (round-off error or half the machine epsilon) is
as follows:
| add_small | 3 flops | 0u² | 7 flops | 2u² | 17 flops | 3u² |
| + - | 6 flops | 0u² | 10 flops | 2u² | 20 flops | 3u² |
| * | 2 flops | 0u² | 6 flops | 2u² | 9 flops | 4u² |
| / | 3* flops | 1u² | 7* flops | 3u² | 28* flops | 6u² |
| reciprocal | 3* flops | 1u² | | | 19* flops | 2.3u² |
The error bounds are mostly tight analytical bounds (except for divisions).[^1]
An asterisk indicates the need for one or two double divisions, which are about
an order of magnitude more expensive than regular flops on a modern CPU.
The table can be distilled into two rules of thumb: double-double arithmetic
roughly doubles the number of significant digits at the cost of a roughly
15x slowdown compared to double arithmetic.
License and Copying
-------------------
Copyright (C) 2023-2025 Markus Wallerberger and others.
Released under the MIT license (see LICENSE for details).