Skip to content

Commit f968805

Browse files
committed
dtostrf fix for remainder leading zeros
Fix remainder to display leading zeros
1 parent 8b1caeb commit f968805

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

hardware/esp8266com/esp8266/cores/esp8266/core_esp8266_noniso.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,10 @@ char * dtostrf(double number, signed char width, unsigned char prec, char *s) {
188188
++out;
189189
}
190190

191-
while(prec-- > 0) {
191+
for (unsigned char decShift = prec; decShift > 0; decShift--) {
192192
remainder *= 10.0;
193193
}
194-
sprintf(out, "%d", (int) remainder);
194+
sprintf(out, "%0*d", prec, (int)remainder);
195195

196196
return s;
197197
}

0 commit comments

Comments
 (0)