diff --git a/CHANGELOG.md b/CHANGELOG.md index 3654430e..22338948 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ HEAD * Store 64-bit numbers (`double` and `long long`) in an additional slot * Reduce the slot size (see table below) * Improve message when user forgets third arg of `serializeJson()` et al. +* Set `ARDUINOJSON_USE_DOUBLE` to `0` by default on 8-bit architectures | Architecture | before | after | |--------------|----------|----------| diff --git a/extras/conf_test/avr.cpp b/extras/conf_test/avr.cpp index 71c08cce..35105ef4 100644 --- a/extras/conf_test/avr.cpp +++ b/extras/conf_test/avr.cpp @@ -8,7 +8,7 @@ static_assert(ARDUINOJSON_SLOT_ID_SIZE == 1, "ARDUINOJSON_SLOT_ID_SIZE"); static_assert(ARDUINOJSON_LITTLE_ENDIAN == 1, "ARDUINOJSON_LITTLE_ENDIAN"); -static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE"); +static_assert(ARDUINOJSON_USE_DOUBLE == 0, "ARDUINOJSON_USE_DOUBLE"); static_assert(sizeof(ArduinoJson::detail::VariantData) == 6, "sizeof(VariantData)"); diff --git a/src/ArduinoJson/Configuration.hpp b/src/ArduinoJson/Configuration.hpp index 8939742b..21006bc3 100644 --- a/src/ArduinoJson/Configuration.hpp +++ b/src/ArduinoJson/Configuration.hpp @@ -56,12 +56,6 @@ # endif #endif -// Store floating-point values with float (0) or double (1) -// https://arduinojson.org/v7/config/use_double/ -#ifndef ARDUINOJSON_USE_DOUBLE -# define ARDUINOJSON_USE_DOUBLE 1 -#endif - // Pointer size: a heuristic to set sensible defaults #ifndef ARDUINOJSON_SIZEOF_POINTER # if defined(__SIZEOF_POINTER__) @@ -73,6 +67,16 @@ # endif #endif +// Store floating-point values with float (0) or double (1) +// https://arduinojson.org/v7/config/use_double/ +#ifndef ARDUINOJSON_USE_DOUBLE +# if ARDUINOJSON_SIZEOF_POINTER >= 4 // 32 & 64 bits systems +# define ARDUINOJSON_USE_DOUBLE 1 +# else +# define ARDUINOJSON_USE_DOUBLE 0 +# endif +#endif + // Store integral values with long (0) or long long (1) // https://arduinojson.org/v7/config/use_long_long/ #ifndef ARDUINOJSON_USE_LONG_LONG