#floating-point #arithmetic-operations #precision #arithmetic #float #numeric

no-std twofloat

Double-double arithmetic functionality

15 unstable releases

0.8.1 Nov 24, 2024
0.7.0 Apr 6, 2023
0.6.1 Nov 17, 2022
0.5.0 Apr 21, 2022
0.1.2 Mar 18, 2020

#125 in Algorithms

Download history 856/week @ 2024-08-17 455/week @ 2024-08-24 459/week @ 2024-08-31 801/week @ 2024-09-07 413/week @ 2024-09-14 502/week @ 2024-09-21 510/week @ 2024-09-28 547/week @ 2024-10-05 362/week @ 2024-10-12 554/week @ 2024-10-19 493/week @ 2024-10-26 344/week @ 2024-11-02 459/week @ 2024-11-09 627/week @ 2024-11-16 1183/week @ 2024-11-23 1342/week @ 2024-11-30

3,694 downloads per month
Used in 5 crates (4 directly)

BSD-3-Clause

130KB
3K SLoC

twofloat

Crate

A double-double arithmetic library for Rust.

This library provides an implementation of double-double arithmetic for the Rust language. Note that this is not the same as the IEEE quadruple-precision floating-point format. Instead, higher precision is obtained by representing the value as the sum of two non-overlapping f64 values.

Operator traits are implemented both for reference and value types where appropriate. The code indicates the source of the algorithms used.

Mathematical constants are available in the twofloat::consts module, which provides the same set of constants as std::f64::consts.

Please note that the implementation of the mathematical functions (exp, powf, etc.) is very preliminary. In particular, they are calculated using operations at the same precision as the result, so they will not return values which are correct to the full precision of the TwoFloat type. This may be addressed in future releases.

Optional features

  • math_funcs - include mathematical functions (enabled by default)
  • serde - enable serialization/deserialization with Serde.
  • std - use std mathematical functions instead of libm.

Known issues

  • The MinGW fma implementation appears to give incorrect results in some cases, so the libm implementation is always used on this platform.

References

  • Mioara Joldeș, Jean-Michel Muller, Valentina Popescu. Tight and rigourous error bounds for basic building blocks of double-word arithmetic. ACM Transactions on Mathematical Software, Association for Computing Machinery, 2017, 44 (2), pp. 1-27. 10.1145/3121432. hal-01351529v3

  • Alan H. Karp, Peter Markstein. High Precision Division and Square Root. ACM Transactions on Mathematical Software, Association for Computing Machinery, 1997, 23 (4), pp. 561-589. 10.1145/279232.279237.

  • S. Chevillard, M. Joldeș and C. Lauter. Sollya: an environment for the development of numerical codes. Mathematical Software - ICMS 2010, pp. 28–31.

Dependencies

~2MB
~49K SLoC