From 8df80c1ce1ee0320cc8781cb9e246dbfc956455c Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Fri, 3 Mar 2023 10:52:08 -0800 Subject: [PATCH] Fix too many decimal places for type --- include/boost/charconv/detail/parser.hpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/boost/charconv/detail/parser.hpp b/include/boost/charconv/detail/parser.hpp index b97fd92..42dcb98 100644 --- a/include/boost/charconv/detail/parser.hpp +++ b/include/boost/charconv/detail/parser.hpp @@ -119,14 +119,15 @@ inline from_chars_result parser(const char* first, const char* last, bool& sign, // if fmt is chars_format::scientific the e is required // if fmt is chars_format::fixed and not scientific the e is disallowed // if fmt is chars_format::general (which is scientific and fixed) the e is optional - while (*next != exp_char && *next != capital_exp_char && next != last) + while (*next != exp_char && *next != capital_exp_char && next != last && i < significand_buffer_size) { significand_buffer[i] = *next; ++next; ++i; } } - else if (i == significand_buffer_size) + + if (i == significand_buffer_size) { // We can not process any more significant figures into the significand so skip to the end // or the exponent part and capture the additional orders of magnitude for the exponent @@ -135,6 +136,11 @@ inline from_chars_result parser(const char* first, const char* last, bool& sign, ++next; ++extra_zeros; } + + if (fractional) + { + extra_zeros = 0; + } } if (next == last)