Renamed base-helpers to numeric_base, and separated numeric_base into header and implementation files

master
Aadhavan Srinivasan 10 months ago
parent a47e598b5c
commit 13da015683

@ -0,0 +1,14 @@
#ifndef _BASE_HELP
#define _BASE_HELP
#include <string>
/* 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

@ -1,13 +1,10 @@
#ifndef _BASE_HELP
#define _BASE_HELP
#include "includes/numeric_base.hpp"
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
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
Loading…
Cancel
Save