diff --git a/include/nlohmann/detail/input/lexer.hpp b/include/nlohmann/detail/input/lexer.hpp index b18893a4d..5c9d5ed5c 100644 --- a/include/nlohmann/detail/input/lexer.hpp +++ b/include/nlohmann/detail/input/lexer.hpp @@ -936,7 +936,7 @@ class lexer : public lexer_base while (*p >= '0' and * p <= '9') { - val = (10 * val) + (*p - '0'); + val = (10U * val) + static_cast((*p - '0')); p++; } diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 18ec30246..b04619fe1 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -9048,7 +9048,7 @@ class lexer : public lexer_base while (*p >= '0' and * p <= '9') { - val = (10 * val) + (*p - '0'); + val = (10U * val) + static_cast((*p - '0')); p++; }