File tree Expand file tree Collapse file tree 1 file changed +3
-0
lines changed Expand file tree Collapse file tree 1 file changed +3
-0
lines changed Original file line number Diff line number Diff line change 2020*/
2121
2222#include " String.h"
23+ #include " Common.h"
2324#include " itoa.h"
2425#include " deprecated-avr-comp/avr/dtostrf.h"
2526
@@ -123,6 +124,7 @@ String::String(float value, unsigned char decimalPlaces)
123124 static size_t const FLOAT_BUF_SIZE = FLT_MAX_10_EXP + FLT_MAX_DECIMAL_PLACES + 1 /* '-' */ + 1 /* '.' */ + 1 /* '\0' */ ;
124125 init ();
125126 char buf[FLOAT_BUF_SIZE];
127+ decimalPlaces = min (decimalPlaces, FLT_MAX_DECIMAL_PLACES);
126128 *this = dtostrf (value, (decimalPlaces + 2 ), decimalPlaces, buf);
127129}
128130
@@ -131,6 +133,7 @@ String::String(double value, unsigned char decimalPlaces)
131133 static size_t const DOUBLE_BUF_SIZE = DBL_MAX_10_EXP + DBL_MAX_DECIMAL_PLACES + 1 /* '-' */ + 1 /* '.' */ + 1 /* '\0' */ ;
132134 init ();
133135 char buf[DOUBLE_BUF_SIZE];
136+ decimalPlaces = min (decimalPlaces, DBL_MAX_DECIMAL_PLACES);
134137 *this = dtostrf (value, (decimalPlaces + 2 ), decimalPlaces, buf);
135138}
136139
You can’t perform that action at this time.
0 commit comments