From dbfb6804c2cab18ee393141841f09aaa9439dfab Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Fri, 19 May 2023 15:36:56 +0200 Subject: [PATCH] Add special handling with exp = -1 to avoid unnecessary fallback --- include/boost/charconv/from_chars.hpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/boost/charconv/from_chars.hpp b/include/boost/charconv/from_chars.hpp index 63f361c..aa23961 100644 --- a/include/boost/charconv/from_chars.hpp +++ b/include/boost/charconv/from_chars.hpp @@ -159,6 +159,13 @@ from_chars_result from_chars_float_impl(const char* first, const char* last, T& value = sign ? static_cast(-0.0L) : static_cast(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(significand) : static_cast(significand)) / 10; + } bool success {}; T return_val {};