sqrt

Arbitrary-Precision Square Root Calculator

This is a Rust command-line utility that calculates the square root of a number to a user-specified number of decimal digits using fixed-point arithmetic. It uses the Malachite library for fast and precise big integer operations.

Features

Usage

You can run the binary in two ways:

1. Command-line Mode

cargo run --release -- [x] [digits]

Example:

$ cargo run --release -- 2 50
√2 = 1.41421356237309504880168872420969807856967187537694...

This calculates √2 to 50 decimal digits.

2. Interactive Mode

If no arguments are given, the program will prompt you for input:

$ cargo run --release
Enter the number :    5
How many digits of √5? :    25
√5 = 2.2360679774997896964091736...

Building

To build the project, make sure you have Rust installed. If not, install it via rustup:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Then clone this repository and build it:

git clone https://github.com/Abhrankan-Chakrabarti/sqrt.git
cd sqrt
cargo build --release

Then run it:

cargo run --release

License

This project is licensed under the MIT License.