LibC: Fix strtod() parsing of negative exponents (#1645)

Before this fix negative exponents were interpreted as positive.
This commit is contained in:
Stephan Unverwerth 2020-04-05 15:32:57 +02:00 committed by GitHub
commit b82a2239c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: sideshowbarker 2024-07-19 07:53:36 +09:00

View file

@ -335,7 +335,9 @@ double strtod(const char* str, char** endptr)
}
if (str[i] == 'e' || str[i] == 'E') {
if (str[i + 1] == '-' || str[i + 1] == '+')
if (str[i + 1] == '-')
exp_val = -atoi(str + i + 2);
else if (str[i + 1] == '+')
exp_val = atoi(str + i + 2);
else
exp_val = atoi(str + i + 1);