#big-float #bignum #numeric

no-std astro-float-num

Multiple precision floating point numbers implemented purely in Rust

19 releases

0.3.5 Mar 21, 2024
0.3.3 Jan 5, 2024
0.3.2 Dec 10, 2023
0.2.2 Nov 28, 2023
0.1.5 Mar 7, 2023

#1248 in Math

Download history 83/week @ 2023-12-22 259/week @ 2023-12-29 240/week @ 2024-01-05 68/week @ 2024-01-12 290/week @ 2024-01-19 183/week @ 2024-01-26 270/week @ 2024-02-02 91/week @ 2024-02-09 293/week @ 2024-02-16 166/week @ 2024-02-23 318/week @ 2024-03-01 487/week @ 2024-03-08 329/week @ 2024-03-15 223/week @ 2024-03-22 227/week @ 2024-03-29 167/week @ 2024-04-05

1,034 downloads per month
Used in 5 crates (2 directly)

MIT license

800KB
18K SLoC

Rust Minimum rustc version Test coverage

Astro-float (astronomically large floating-point numbers) is an arbitrary precision floating-point numbers library designed for performance, portability, and implemented 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.

What's new

Information about the latest changes is available in Release notes

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 rounded to the nearest even number.

use astro_float::Consts;
use astro_float::RoundingMode;
use astro_float::ctx::Context;
use astro_float::expr;

// Create a context with precision 1024, and rounding to even.
let mut ctx = Context::new(1024, RoundingMode::ToEven, 
    Consts::new().expect("Constants cache initialized"),
    -10000, 10000);

// Compute pi: pi = 6*arctan(1/sqrt(3))
let pi = expr!(6 * atan(1 / sqrt(3)), &mut ctx);

// Use library's constant value for verifying the result.
let pi_lib = ctx.const_pi();

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

Performance

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

Contributing

Issues regarding bugs or new features can be opened here: https://github.com/stencillogic/astro-float/issues

For more information please check CONTRIBUTING.md

Dependencies

~0.5–0.8MB
~17K SLoC