diff --git a/src/ArduinoJson/Json/TextFormatter.hpp b/src/ArduinoJson/Json/TextFormatter.hpp index 23d16d03..18694f14 100644 --- a/src/ArduinoJson/Json/TextFormatter.hpp +++ b/src/ArduinoJson/Json/TextFormatter.hpp @@ -92,9 +92,9 @@ class TextFormatter { unsigned_type unsigned_value; if (value < 0) { writeRaw('-'); - unsigned_value = static_cast(-value); + unsigned_value = unsigned_type(unsigned_type(~value) + 1); } else { - unsigned_value = static_cast(value); + unsigned_value = unsigned_type(value); } writeInteger(unsigned_value); }