summaryrefslogtreecommitdiffstats
path: root/strtod.c
diff options
context:
space:
mode:
Diffstat (limited to 'strtod.c')
-rw-r--r--strtod.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/strtod.c b/strtod.c
index fe7319887..457cbcd9a 100644
--- a/strtod.c
+++ b/strtod.c
@@ -64,12 +64,9 @@ double strtod_flags(const char *str, const char **ptr, unsigned int flags)
}
if (c >= '0' && c <= '9') {
numbers++;
- if (dot) {
- decimal /= 10;
- val += (c - '0') * decimal;
- } else {
- val = (val * 10) + (c - '0');
- }
+ val = (val * 10) + (c - '0');
+ if (dot)
+ decimal *= 10;
continue;
}
if (c != 'e' && c != 'E')
@@ -111,9 +108,9 @@ double strtod_flags(const char *str, const char **ptr, unsigned int flags)
while (exponent-- > 0) {
if (esign)
- val /= 10;
+ decimal *= 10;
else
- val *= 10;
+ decimal /= 10;
}
}
@@ -122,7 +119,7 @@ done:
goto no_conversion;
if (ptr)
*ptr = p-1;
- return sign ? -val : val;
+ return (sign ? -val : val) / decimal;
no_conversion:
if (ptr)