A number base is the number of digits or combination of digits that a system uses to represent numbers.
This Base Converter program allows you to convert numbers between different bases:
- Binary (Base-2) to Decimal (Base-10)
- Decimal (Base-10) to Hexadecimal (Base-16)
- Hexadecimal (Base-16) to Binary (Base-2)
- Binary (Base-2) to Hexadecimal (Base-16)
- Decimal (Base-10) to Binary (Base-2)
- Hexadecimal (Base-16) to Decimal (Base-10)
- Binary Numbers (Base-2): A number system using only two digits,
0
and1
. Represents OFF and ON states in electronic systems. - Decimal Numbers (Base-10): The standard number system consisting of digits
0
through9
. - Hexadecimal Numbers (Base-16): A base-16 system using symbols
0-9
and lettersA-F
to represent values from0
to15
. Useful for compactly representing large numbers.
To compile the program, use the following command:
gcc *.c -lm -o base_converter
sudo mv base_converter /usr/local/bin/
nano ~/.bashrc # or nano ~/.zshrc if using zsh
export PATH="$HOME/my_programs:$PATH"
source ~/.bashrc # or source ~/.zshrc if using zsh
base_converter
-
Choose the format you are converting from:
- Enter
1
for Binary - Enter
2
for Decimal - Enter
3
for Hexadecimal - Enter
0
for Help
- Enter
-
Select the format you want to convert to:
- Enter
1
for Binary - Enter
2
for Decimal - Enter
3
for Hexadecimal
- Enter
-
Enter the number to be converted:
- For Binary to Decimal: Enter a binary number.
- For Decimal to Binary: Enter a decimal number.
- For Binary to Hexadecimal: Enter a binary number.
- For Decimal to Hexadecimal: Enter a decimal number.
- For Hexadecimal to Binary: Enter a hexadecimal number.
- For Hexadecimal to Decimal: Enter a hexadecimal number.
-
View the conversion result.
-
Decide if you want to perform another conversion or exit the program:
- Type
yes
to perform another conversion. - Type
no
to exit the program.
- Type
- Clear Screen: Automatically clears the terminal for a cleaner interface.
- Loading Indicator: Provides visual feedback during conversions.
- Help Menu: Easily accessible help instructions to guide users.
Feel free to contribute to this project. Open an issue or submit a pull request on GitHub.