Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions cores/arduino/WString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include <float.h>

#include "WString.h"
#include "itoa.h"
#include "avr/dtostrf.h"
Expand Down Expand Up @@ -110,14 +112,14 @@ String::String(unsigned long value, unsigned char base)
String::String(float value, unsigned char decimalPlaces)
{
init();
char buf[33];
char buf[FLT_MAX_10_EXP + 4 + decimalPlaces]; // +4, one for: 10, -, ., \0
*this = dtostrf(value, (decimalPlaces + 2), decimalPlaces, buf);
}

String::String(double value, unsigned char decimalPlaces)
{
init();
char buf[33];
char buf[DBL_MAX_10_EXP + 4 + decimalPlaces]; // +4, one for: 10, -, ., \0
*this = dtostrf(value, (decimalPlaces + 2), decimalPlaces, buf);
}

Expand Down