Rust Minimum rustc version

Astro-float (astronomically large floating point numbers) is a library that implements arbitrary precision floating point numbers purely in Rust.

The library implements the basic operations and functions. It uses classical algorithms such as Karatsuba, Toom-Cook, Schönhage-Strassen algorithm, and others.

The library can work without the standard library provided there is a memory allocator.

Usage

Below is an example of using the library. For more information please refer to the library documentation: https://docs.rs/astro-float/latest/astro_float/

Calculate Pi with 1024 bit precision:

``` rust use astrofloat::BigFloat; use astrofloat::Consts; use astro_float::RoundingMode;

// Precision with some space for error. let p = 1024 + 8;

// Rounding of all operations let rm = RoundingMode::ToEven;

// Initialize mathematical constants cache let mut cc = Consts::new().unwrap();

// Compute pi: pi = 6*arctan(1/sqrt(3)) let six = BigFloat::fromword(6, 1); let three = BigFloat::fromword(3, p);

let n = three.sqrt(p, rm); let n = n.reciprocal(p, rm); let n = n.atan(p, rm, &mut cc); let mut pi = six.mul(&n, p, rm);

// Reduce precision to 1024 pi.set_precision(1024, rm).expect("Precision updated");

// Use library's constant for verifying the result let pi_lib = cc.pi(1024, rm).unwrap().into();

// Compare computed constant with library's constant asserteq!(pi.cmp(&pilib), Some(0));

// Print using decimal radix. println!("{}", pi); ```

Correctness

The source code contains integration tests for many operations, including arithmetic operations, rounding, mathematical functions, constants, and other, which check whether these computations produce identical results with rug (MPFR).

Performance

Benchmark can be found here: https://github.com/stencillogic/bigfloat-bench.

Roadmap

Future improvements include the implementation of faster mathematical function algorithms for arguments with large precision, such as AGM implementation for calculating the logarithm, and faster trigonometric functions.

Contributing

The library is still young and may lack some features or contain bugs. Issues for these or other cases can be opened here: https://github.com/stencillogic/astro-float/issues