Prechádzať zdrojové kódy

Fixed double formatting issue

Benoit Blanchon 11 rokov pred
rodič
commit
9da7dce310
2 zmenil súbory, kde vykonal 3 pridanie a 3 odobranie
  1. 1 1
      src/Arduino/Print.cpp
  2. 2 2
      src/Internals/JsonParser.cpp

+ 1 - 1
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);
 }
 

+ 2 - 2
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;