hello
i want to convert a hex number in string to a decimal number in string i have this function but i dont know why it is not working. could you please help me?
for (size_t i = 0; i < senderNumber.length(); i += 2) {
String hexByte = senderNumber.substring(i, i + 2); // seperating each 2 character of String and put it to another string (hexByte)
char hexByteChars[3];
hexByte.toCharArray(hexByteChars, 3); // converting hexByte to chararray
unsigned long decimalValue = strtoul(hexByteChars, nullptr, 16); //converting HEX to Decimal
decimalString += String(decimalValue); // put the decimalValue to decimalString
}
return decimalString; // returning the decimalString
}
Just for the record: you do not convert a string with a hex number to dec (which would have 114 bits), you convert a string of 2-byte hex to a string of 1 byte chars