i want to convert string for example "68976543210" to unsigned long long(64 bit) in mega2560, do is possible?
String x="68976543210";
unsigned long long y=?;
i want to convert string for example "68976543210" to unsigned long long(64 bit) in mega2560, do is possible?
String x="68976543210";
unsigned long long y=?;
How about this way to do the conversion(s).
I deliberately use no Strings.
long long atoll(const char* ptr) {
long long result = 0;
while (*ptr && isdigit(*ptr)) {
result *= 10;
result += *ptr++ - '0';
}
return result;
}
void setup() {
Serial.begin(115200);
char buf[7];
unsigned long long y = atoll("68976543210");
sprintf(buf, "%06ld", (long)(y % 1000000));
Serial.print(F("y = "));
Serial.print((long)(y / 1000000));
Serial.print(buf);
Serial.println();
}
void loop() {}
y = 68976543210