diff --git a/includes/numeric_base.hpp b/includes/numeric_base.hpp new file mode 100644 index 0000000..eced847 --- /dev/null +++ b/includes/numeric_base.hpp @@ -0,0 +1,14 @@ +#ifndef _BASE_HELP +#define _BASE_HELP +#include + +/* Convert the given value from the given base, to base 10 */ +int to_decimal(std::string num, int from_base); + +/* Convert the given value from base 10 to the given base */ +std::string from_decimal(int num, int to_base); + +/* Convert the given value from 'from_base', to 'to_base' */ +std::string base_convert(std::string num, int from_base, int to_base); + +#endif diff --git a/includes/base-helpers.hpp b/numeric_base.cpp similarity index 90% rename from includes/base-helpers.hpp rename to numeric_base.cpp index 1c79dfd..4acb52f 100644 --- a/includes/base-helpers.hpp +++ b/numeric_base.cpp @@ -1,13 +1,10 @@ -#ifndef _BASE_HELP -#define _BASE_HELP +#include "includes/numeric_base.hpp" #include #include -#include #include std::string possible_chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; -/* Convert the given value from the given base, to base 10 */ int to_decimal(std::string num, int from_base) { char current_char = 0; int index = 0; @@ -48,4 +45,4 @@ std::string base_convert(std::string num, int from_base, int to_base) { return result; } -#endif +