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.
This project provides a basic CLI for converting decimal numbers to their binary representations.
To use this tool, run it from the command line:
cargo run [optional_decimal_number]
Alternatively, precompiled binaries for most platforms are available.
- Iterative: Uses a loop to perform the conversion. It divides the decimal number by 2 iteratively and gets the remainder.
- Recursive: Same algorithm as iterative method, but recursively.
- Lookup Table: Uses a lookup table that contains all possible 4-bit binary strings for faster conversion (generally the fastest method).
- 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.
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.
This project is open-source and available under the MIT License.