compute-pi 0.2.0

A Rust library for computing π to a high degree of precision.
Documentation
compute-pi-0.2.0 has been yanked.

compute-pi

This crate provides a function to compute the value of Pi to a specified number of digits using the Gauss-Legendre algorithm.

Installation

You can include this crate in your Cargo.toml file as follows:

[dependencies]
compute-pi = "0.2.0"

Usage

To use the compute_pi function in your Rust code, add the following to your crate root:

use compute_pi::compute_pi;

fn main() {
    // Specify the number of digits of Pi you want to compute
    let digits = 100;

    // Compute Pi
    let pi = compute_pi(digits);

    // Print calculated decimal
    let pi_str = pi.to_string_radix(10, Some(digits + 5));
    let pi_str_trimmed = &pi_str[0..(digits + 2)];
    println!("Pi to {} decimal places: {}", digits, pi_str_trimmed);
}

Command Line Usage

You can also use the compute-pi command from the command line. After installing the crate with

cargo install compute-pi

run the following command:

compute-pi <digits>

Replace <digits> with the number of digits of Pi you want to compute. For example:

compute-pi 100

This will print the value of Pi to 100 decimal places.

License

This crate is licensed under the MIT license. See the LICENSE file for details.