Num converter is a program designed to demonstrate the debugging process using tools such as GDB and Valgrind.
- Makefile
- main.cpp: Handles user input and calls appropriate functions.
- BaseNumber.h/cpp: Contains the main conversion logic.
- BaseCalc.h/cpp: Includes some arithmetic operations performed on BaseNumber.
- util.hpp: Includes utilities used by the program and manages input validation for automatic mode.
- Clone this repository using
git clone. - Run
maketo execute the Makefile. (Note: There might be issues.)
Run the program with the following command-line arguments: ./calculator ifile ofile <0 | 1>
In automatic mode, the program reads input from an input file (ifile) if prompted by the user. Valid commands include:
Help: Displays valid commands (This Page)Init: Reads the numbers fromifileand stores them in a vector.Convert: Converts the arrayHEX: Converts read values to hexadecimal.BIN: Converts read values to binary.DEC: Converts read values to decimal.
Save: Saves the array toofile.Print: Prints the active working array.Total: Prints the total of the active working array.Stop: Exits the program.
In manual mode, the user is prompted to enter a number, using the prefixes "0d" for decimal, "0b" for binary, and "0x" for hexadecimal. After entering the number, the user can perform the following operations using the index:
- Exit: Exits the program.
- Convert to binary: Converts the previously entered number to binary.
- Convert to hexadecimal: Converts the previously entered number to hexadecimal.
- Convert to decimal: Converts the previously entered number to decimal.
- Arithmetic Operations: Prompts the user to enter another number and perform addition or subtraction.