Skip to content

A high-precision square root calculator written in Rust using the Malachite library. Supports both interactive and command-line modes, allowing users to compute the square root of any positive integer to an arbitrary number of decimal digits with fixed-point accuracy.

License

Notifications You must be signed in to change notification settings

Abhrankan-Chakrabarti/sqrt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

  • Computes the square root of any positive integer with high precision
  • Supports both interactive mode and command-line arguments
  • Clean fixed-point implementation
  • Uses Malachite for efficient arithmetic

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.

About

A high-precision square root calculator written in Rust using the Malachite library. Supports both interactive and command-line modes, allowing users to compute the square root of any positive integer to an arbitrary number of decimal digits with fixed-point accuracy.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages