Merge pull request #187 from Neptilo/master

Fix parsing double with negative exponent
This commit is contained in:
Syoyo Fujita
2018-11-06 00:28:10 +09:00
committed by GitHub

View File

@@ -605,19 +605,9 @@ static bool tryParseDouble(const char *s, const char *s_end, double *result) {
} }
assemble : assemble :
*result = (sign == '+' ? 1 : -1) *
{ (exponent ? std::ldexp(mantissa * std::pow(5.0, exponent), exponent)
// = pow(5.0, exponent); : mantissa);
double a = 1.0;
for (int i = 0; i < exponent; i++) {
a = a * 5.0;
}
*result =
//(sign == '+' ? 1 : -1) * ldexp(mantissa * pow(5.0, exponent), exponent);
(sign == '+' ? 1 : -1) * (mantissa * a) *
static_cast<double>(1ULL << exponent); // 5.0^exponent * 2^exponent
}
return true; return true;
fail: fail:
return false; return false;