File tree 1 file changed +3
-0
lines changed
1 file changed +3
-0
lines changed Original file line number Diff line number Diff line change 20
20
*/
21
21
22
22
#include " String.h"
23
+ #include " Common.h"
23
24
#include " itoa.h"
24
25
#include " deprecated-avr-comp/avr/dtostrf.h"
25
26
@@ -123,6 +124,7 @@ String::String(float value, unsigned char decimalPlaces)
123
124
static size_t const FLOAT_BUF_SIZE = FLT_MAX_10_EXP + FLT_MAX_DECIMAL_PLACES + 1 /* '-' */ + 1 /* '.' */ + 1 /* '\0' */ ;
124
125
init ();
125
126
char buf[FLOAT_BUF_SIZE];
127
+ decimalPlaces = min (decimalPlaces, FLT_MAX_DECIMAL_PLACES);
126
128
*this = dtostrf (value, (decimalPlaces + 2 ), decimalPlaces, buf);
127
129
}
128
130
@@ -131,6 +133,7 @@ String::String(double value, unsigned char decimalPlaces)
131
133
static size_t const DOUBLE_BUF_SIZE = DBL_MAX_10_EXP + DBL_MAX_DECIMAL_PLACES + 1 /* '-' */ + 1 /* '.' */ + 1 /* '\0' */ ;
132
134
init ();
133
135
char buf[DOUBLE_BUF_SIZE];
136
+ decimalPlaces = min (decimalPlaces, DBL_MAX_DECIMAL_PLACES);
134
137
*this = dtostrf (value, (decimalPlaces + 2 ), decimalPlaces, buf);
135
138
}
136
139
You can’t perform that action at this time.
0 commit comments