From ae044c19054f0706380bd4ed61c26f4ac2c62ab0 Mon Sep 17 00:00:00 2001 From: Rockingcool Date: Sun, 10 Mar 2024 19:26:39 -0500 Subject: [PATCH] Convert character to upper-case before converting to decimal --- numeric_base.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/numeric_base.cpp b/numeric_base.cpp index 389fa72..4850588 100644 --- a/numeric_base.cpp +++ b/numeric_base.cpp @@ -1,6 +1,7 @@ #include "includes/numeric_base.hpp" #include #include +#include #include std::string possible_chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; @@ -15,7 +16,7 @@ unsigned int to_decimal(std::string num, int from_base) { compute the value using */ for (int i=0; i < (int)num.length(); i++) { current_char = num.at(i); - index = possible_chars.find(current_char); + index = possible_chars.find(toupper(current_char)); // Convert the character to upper-case, so that the earliest match is detected value += pow(from_base, num.length() - i - 1) * index; }