Skip to content

Commit e792ba2

Browse files
bigdinotechcalvinatintel
authored andcommitted
Fix bug when using StringConstructor with doubles
-Fixes issue of StringContructor instability with doubles
1 parent acc4b38 commit e792ba2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cores/arduino/WString.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ String::String(float value, unsigned char decimalPlaces)
136136
int len = digitsBe4Decimal(value);
137137
init();
138138

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

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

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

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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy