6 releases (3 breaking)

0.4.1 Jul 20, 2024
0.4.0 Jul 20, 2024
0.3.1 Oct 12, 2020
0.3.0 Apr 14, 2018
0.1.1 Feb 28, 2016

#149 in Algorithms

Download history 1799/week @ 2024-08-10 1855/week @ 2024-08-17 2142/week @ 2024-08-24 2238/week @ 2024-08-31 1934/week @ 2024-09-07 1645/week @ 2024-09-14 1511/week @ 2024-09-21 1756/week @ 2024-09-28 1443/week @ 2024-10-05 1455/week @ 2024-10-12 1703/week @ 2024-10-19 1897/week @ 2024-10-26 1860/week @ 2024-11-02 1704/week @ 2024-11-09 1933/week @ 2024-11-16 1348/week @ 2024-11-23

7,141 downloads per month
Used in 50 crates (4 directly)

MIT/Apache

59KB
1.5K SLoC

(More or less) accurate floating point algorithms

GitHub Actions status Documentation: hosted License: Apache License 2.0 or MIT latest GitHub release crate on crates.io

This crate provides several algorithms that implement highly accurate or even guaranteed correct sum and dot product for floating-point numbers without resorting to arbitrary precision arithmetic. These algorithms are available:

Usage

Add the accurate crate as a dependency in your Cargo.toml:

[dependencies]
accurate = "0.4"

Then use it in your program like this:

extern crate accurate;

use accurate::traits::*;
use accurate::sum::Sum2;

fn main() {
  let x = vec![1.0, 2.0, 3.0];
  let s = x.sum_with_accumulator::<Sum2<_>>();
  assert_eq!(6.0f64, s);
}

Documentation

Documentation for the latest version of the crate is on docs.rs.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~1.7–2.3MB
~51K SLoC