Skip to content

Commit

Permalink
Fix bug when using StringConstructor with doubles
Browse files Browse the repository at this point in the history
-Fixes issue of StringContructor instability with doubles
  • Loading branch information
bigdinotech authored and calvinatintel committed Jun 1, 2016
1 parent acc4b38 commit e792ba2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cores/arduino/WString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ String::String(float value, unsigned char decimalPlaces)
int len = digitsBe4Decimal(value);
init();

if(decimalPlaces) len = 1 + ((int)decimalPlaces & 0x0FF);
if(decimalPlaces) len += 1 + ((int)decimalPlaces & 0x0FF);

char buf[len+1];
*this = dtostrf(value, 0, decimalPlaces, buf);
Expand All @@ -147,7 +147,7 @@ String::String(double value, unsigned char decimalPlaces)
int len = digitsBe4Decimal(value);
init();

if(decimalPlaces) len = 1 + ((int)decimalPlaces & 0x0FF);
if(decimalPlaces) len += 1 + ((int)decimalPlaces & 0x0FF);

char buf[len+1];
*this = dtostrf(value, 0, decimalPlaces, buf);
Expand Down

0 comments on commit e792ba2

Please sign in to comment.