Skip to content

Latest commit

 

History

History
43 lines (27 loc) · 1.92 KB

README.md

File metadata and controls

43 lines (27 loc) · 1.92 KB

Decimal to Binary Converter in Rust

GitHub GitHub repo size GitHub issues GitHub last commit

A simple Rust implementation of a decimal to binary converter, inspired by my previous C version. I'm using this project to learn Rust and explore its features.

Overview

This project provides a basic CLI for converting decimal numbers to their binary representations.

Usage

To use this tool, run it from the command line:

cargo run [optional_decimal_number]

Alternatively, precompiled binaries for most platforms are available.

Conversion Methods

  1. Iterative: Uses a loop to perform the conversion. It divides the decimal number by 2 iteratively and gets the remainder.
  2. Recursive: Same algorithm as iterative method, but recursively.
  3. Lookup Table: Uses a lookup table that contains all possible 4-bit binary strings for faster conversion (generally the fastest method).

Features

  • Supports conversion of large numbers using the num_bigint crate
  • Measures and displays the mean time taken for N iterations for each conversion method.

If you provide a decimal number as an argument, the program will use that for conversions. Otherwise, it will prompt you to enter a number.

Contributing

This project was created as a learning exercise. While it's primarily for personal use, suggestions and improvements are welcome. Feel free to open an issue or submit a pull request if you have ideas to enhance its functionality.

License

This project is open-source and available under the MIT License.