Add special handling with exp = -1 to avoid unnecessary fallback

This commit is contained in:
Matt Borland
2023-05-19 15:36:56 +02:00
parent 19e8ea55fb
commit dbfb6804c2

View File

@@ -159,6 +159,13 @@ from_chars_result from_chars_float_impl(const char* first, const char* last, T&
value = sign ? static_cast<T>(-0.0L) : static_cast<T>(0.0L);
return r;
}
else if (exponent == -1)
{
// A full length significand e.g. -1985444280612224 with a power of -1 sometimes
// fails in compute_float64 but is trivial to calculate
// Found investigating GitHub issue #47
value = (sign ? -static_cast<T>(significand) : static_cast<T>(significand)) / 10;
}
bool success {};
T return_val {};