From 9da7dce3101b29e4e28c085fbc9395f8bfdc1ec8 Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Sat, 1 Nov 2014 13:30:37 +0100 Subject: [PATCH] Fixed double formatting issue --- src/Arduino/Print.cpp | 2 +- src/Internals/JsonParser.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Arduino/Print.cpp b/src/Arduino/Print.cpp index 877447d7..6525f04a 100644 --- a/src/Arduino/Print.cpp +++ b/src/Arduino/Print.cpp @@ -19,7 +19,7 @@ size_t Print::print(const char s[]) { size_t Print::print(double value, int digits) { char tmp[32]; - sprintf(tmp, "%.*g", digits + 1, value); + sprintf(tmp, "%.*f", digits, value); return print(tmp); } diff --git a/src/Internals/JsonParser.cpp b/src/Internals/JsonParser.cpp index d7fe1fb0..1df73876 100644 --- a/src/Internals/JsonParser.cpp +++ b/src/Internals/JsonParser.cpp @@ -117,9 +117,9 @@ void JsonParser::parseNumberTo(JsonValue &destination) { if (*endOfLong == '.') { // stopped on a decimal separator - double douleValue = strtod(_ptr, &_ptr); + double doubleValue = strtod(_ptr, &_ptr); int decimals = _ptr - endOfLong - 1; - destination.set(douleValue, decimals); + destination.set(doubleValue, decimals); } else { _ptr = endOfLong; destination = longValue;