|
|
@ -87,3 +87,23 @@ char* convertIntToHex(int input){ |
|
|
|
}while(input != 0); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
unsigned int convertHexStrToInt(char* input){ |
|
|
|
unsigned int result = 0; |
|
|
|
int index = strlen(input) - 1; |
|
|
|
int exponent = 0; |
|
|
|
while(index >= 0){ |
|
|
|
switch(input[index]){ |
|
|
|
case 'A': case 'a': result += 10 * pow(16, exponent); break; |
|
|
|
case 'B': case 'b': result += 11 * pow(16, exponent); break; |
|
|
|
case 'C': case 'c': result += 12 * pow(16, exponent); break; |
|
|
|
case 'D': case 'd': result += 13 * pow(16, exponent); break; |
|
|
|
case 'E': case 'e': result += 14 * pow(16, exponent); break; |
|
|
|
case 'F': case 'f': result += 15 * pow(16, exponent); break; |
|
|
|
default: result += (input[index] - '0') * pow(16, exponent); break; |
|
|
|
} |
|
|
|
index--; |
|
|
|
exponent++; |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |