Binary.cpp - Number Base Converter
This C++ program serves as a versatile number base converter. It prompts the user to specify a base (binary, octal, decimal, or hexadecimal) and then accepts multiple number inputs in that base. For each valid input, it validates the number, converts it to decimal internally, and displays the equivalent representations in all four bases: decimal, binary, octal, and hexadecimal. The program features colored console output using ANSI escape codes for an enhanced user interface and continues processing inputs until the user interrupts with Ctrl+C.
Supported bases:
-
2: Binary (digits: 0, 1)
-
8: Octal (digits: 0-7)
-
10: Decimal (digits: 0-9)
-
16: Hexadecimal (digits: 0-9, A-F, a-f)
Features:
-
Input validation for each base
-
Conversion functions for binary, octal, and hexadecimal output
-
Error handling for invalid inputs and unsupported bases
-
Interactive loop for multiple conversions