Skip to content

Commit 7bd93b3

Browse files
committed
Jira-584: String constructor create floating point string with incorrect number of decimal places.
1 parent 4d1014f commit 7bd93b3

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

cores/arduino/stdlib_noniso.cpp

+2-5
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,11 @@ char * dtostrf(double number, unsigned char width, unsigned char prec, char *s)
202202

203203
// Print the decimal point, but only if there are digits beyond
204204
if (prec > 0) {
205-
*out = '.';
206-
++out;
207-
prec--;
205+
*out++ = '.';
208206
// Copy character by character to 'out' string
209207
for (unsigned char decShift = prec; decShift > 0; decShift--) {
210208
remainder *= 10.0;
211-
sprintf(out, "%d", (int)remainder);
212-
out++;
209+
out += sprintf(out, "%d", (int)remainder);
213210
remainder -= (double)(int)remainder;
214211
}
215212
}

0 commit comments

Comments
 (0)