Commit 6f51994a authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

We are more worried about mantissa overrun than precision, so use doubles

for the mantissa and exponent.  This may increase the error by up
to one bit in last position.
parent 65cc39af
......@@ -53,7 +53,7 @@ static const char err_invalid_suff[] = "Invalid suffix";
double
VNUMpfx(const char *p, const char **t)
{
intmax_t m = 0, ee = 0;
double m = 0., ee = 0.;
double ms = 1.0;
double es = 1.0, e = 1.0, ne = 0.0;
......@@ -68,7 +68,7 @@ VNUMpfx(const char *p, const char **t)
for (; *p != '\0'; p++) {
if (isdigit(*p)) {
m = m * 10 + *p - '0';
m = m * 10. + *p - '0';
e = ne;
if (e)
ne = e - 1.0;
......@@ -86,7 +86,7 @@ VNUMpfx(const char *p, const char **t)
if (!isdigit(*p))
return (nan(""));
for (; isdigit(*p); p++)
ee = ee * 10 + *p - '0';
ee = ee * 10. + *p - '0';
}
while (isspace(*p))
p++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment