/base_convert_cpp

Convert from one base to another. Binary, octal, hexadecimal, decimal, etc.

Primary LanguageC++BSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

BaseConvert

Note

This library is designed to work with the string representation of numbers. Basically you input a number as a string and get the output as a string. This was done for a specific use case

Convert from one base to another. Binary, octal, hexadecimal, decimal, etc
Supports base with 2-32 bits
Average performance is 200 nanoseconds per conversion (0.0002 milliseconds)
Check out usage_example.cpp for simplest implementation
Also, you can import files from lib directory to your project and use BaseConvert easily (check out lib_usage.cpp)

Examples

Convert from binary to decimal:

BaseConvert bc;
bc.convert("11111101000", 2, 10)

Convert from binary to hexadecimal:

BaseConvert bc;
bc.convert("11111101000", 2, 16)

Convert from hexadecimal to decimal:

BaseConvert bc;
std::cout << convertBase("7E8", 16, 10)

Suggestions

Feel free to suggest any changes 😊