Rust Minimum rustc version

Note. This release besides many improvements has a breaking change: now many operations accept the output precision as an argument. Previously, the resulting precision was computed as the maximum precision of the input arguments.


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::BigFloatNumber; use astrofloat::Consts; use astrofloat::RoundingMode; use astrofloat::Radix; use astro_float::Error;

// 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 = BigFloatNumber::fromword(6, 1).unwrap(); let three = BigFloatNumber::fromword(3, p).unwrap();

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

// Reduce precision to 1024 pi.set_precision(1024, rm).unwrap();

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

// Compare computed constant with library's constant assert!(pi.cmp(&pi_lib) == 0);

// Print computed result as decimal number let s = pi.format(Radix::Dec, rm).unwrap(); println!("{}", s); ```

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