This is a command line tool written in Rust that allows you to do math with binary numbers.
./bin-calculator
Enter your expression: (101 + 11) * 10
10000
You can also provide the expression through the command line arguments, but you will need to escape special characters.
Example in bash:
./bin-calculator \(101 + 11\) \* 10
10000
Five operations are supported:
- Multiplication (
*) - Division (
/) - Addition (
+) - Subtraction (binary
-) - Negation (unary
-)
Binary numbers are interpreted as two's complement 32-bit integers (i32 in Rust)
./bin-calculator -10
11111111111111111111111111111110
- Clone the repository.
- Run
cargo build --releasein the directory you cloned to. - The executable will be in
bin-calculator/target/release/bin-calculator, (bin-calculator.exefor Windows) feel free to move it to where you need it. - Execute the executable!
- You can also run
cargo runto build and execute the program in one step.