diff --git a/include/nlohmann/detail/input/lexer.hpp b/include/nlohmann/detail/input/lexer.hpp index 62d517e86..4c3665593 100644 --- a/include/nlohmann/detail/input/lexer.hpp +++ b/include/nlohmann/detail/input/lexer.hpp @@ -1538,7 +1538,10 @@ scan_number_done: position.chars_read_current_line += (len - 1); return integer_result; } - // the value overflowed: fall through and let the float tail handle it + // The value does not fit an integer, so this token converts as a + // float. Recording that here keeps convert_number() below from + // repeating the integer attempt that just failed. + number_type = token_type::value_float; } #endif diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 9ba0445a3..955add0ef 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -9885,7 +9885,10 @@ scan_number_done: position.chars_read_current_line += (len - 1); return integer_result; } - // the value overflowed: fall through and let the float tail handle it + // The value does not fit an integer, so this token converts as a + // float. Recording that here keeps convert_number() below from + // repeating the integer attempt that just failed. + number_type = token_type::value_float; } #endif