Closed
Description
According to the Atmel reference manual, dtostrf has a width parameter defined as:
minimum field width of the output string (including the '.' and the possible sign for negative values)
width is signed value, negative for left adjustment".
The current implementation of this for esp8266 adds additional space in front of the decimal point when given a small (or negative) value for width
. This is a regression — a previous version of this project did not have this issue. However I am not sure when it was introduced.
f = -8.375;
dtostrf(f, 0, 3, tmp); // "-8 .375"
dtostrf(f, -1, 3, tmp); // "-8 .375"
dtostrf(f, 1, 3, tmp); // "-8 .375"
dtostrf(f, -2, 3, tmp); // "-8 .375"
dtostrf(f, 2, 3, tmp); // "-8.375"
dtostrf(f, -7, 3, tmp); // "-8 .375"
dtostrf(f, 7, 3, tmp); // " -8.375"
f = 3.625;
dtostrf(f, 0, 3, tmp); // "3 .625"
dtostrf(f, -1, 3, tmp); // "3 .625"
dtostrf(f, 1, 3, tmp); // "3 .625"
dtostrf(f, -2, 3, tmp); // "3 .625"
dtostrf(f, 2, 3, tmp); // "3 .625"
dtostrf(f, -7, 3, tmp); // "3 .625"
dtostrf(f, 7, 3, tmp); // " 3.625"
Metadata
Metadata
Assignees
Labels
No labels