I do not have access to anything like strtoull
on my actual platform, so I need to find/handroll one. I've tried all four from this answer and they all give me the same, wrong answer, on my windows testing platform. I also tried on online compilers.
One of the functions is
unsigned long long strtoull_simple(const char *s) {
unsigned long long sum = 0;
while (*s) {
sum = sum*10 + (*s++ - '0');
}
return sum;
}
And given "87ddb08343547aec" it produces 9277008343552481
instead of the real value 9790175242790140652
evident here and also evident if you use strtoull
where available. Why do all of those functions fail to provide the correct value?