Skip to content

dtostrf adds extra space before decimal #726

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lukecyca opened this issue Aug 27, 2015 · 6 comments
Closed

dtostrf adds extra space before decimal #726

lukecyca opened this issue Aug 27, 2015 · 6 comments

Comments

@lukecyca
Copy link

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"
@lukecyca
Copy link
Author

Pinging @martinayotte, @Makuna, and @Links2004 who have worked on dtostrf() recently.

@martinayotte
Copy link
Contributor

Hi likecyca,
I've submitted a patch about 20 days ago related to dtostrf().
Are you actually using the HEAD of the github ?
Because the previous version had so many bugs, as described in this PR, even a big one where sqrt(2) was shown as "1 .00000000002147483647" :
#664
Maybe there are still some others bugs, since they so many use cases to check.
(BTW, this latest version was given to me by Odometer on Arduino forum, see also thread : http://forum.arduino.cc/index.php?topic=329949.45 )

@lukecyca
Copy link
Author

Thank you @martinayotte, it is indeed fixed with your patch. I had been using the stable/staging releases.

Great work on the improvement. Thanks again.

@paulhayes
Copy link

Would be great to see this roll out into stable. Had to switch my project to staging, yet it's been fixed for quite a while now.

@martinayotte
Copy link
Contributor

The stable version is outdated of July.
I think it is only that IGRR couldn't settled is mind about the stability of Staging and then to tag it as Stable.
There is so much new code in Staging needed for everyone that I consider it as the MainDev branch, while the Stable is some kind of "archive" branch.

@paulhayes
Copy link

That's not good, especially when the Readme directs people to the "archive"
branch by default.

Also semantics are important.

On Thu, 19 Nov 2015 01:25 martinayotte notifications@github.com wrote:

The stable version is outdated of July.
I think it is only that IGRR couldn't settled is mind about the stability
of Staging and then to tag it as Stable.
There is so much new code in Staging needed for everyone that I consider
it as the MainDev branch, while the Stable is some kind of "archive" branch.


Reply to this email directly or view it on GitHub
#726 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants