Use sprintf to output floats in Print/dtostrf by earlephilhower · Pull Request #7068 · esp8266/Arduino · GitHub
Skip to content

Use sprintf to output floats in Print/dtostrf#7068

Merged
earlephilhower merged 2 commits into
esp8266:masterfrom
earlephilhower:dtostrf_to_printf
Feb 10, 2020
Merged

Use sprintf to output floats in Print/dtostrf#7068
earlephilhower merged 2 commits into
esp8266:masterfrom
earlephilhower:dtostrf_to_printf

Conversation

@earlephilhower

Copy link
Copy Markdown
Collaborator

Fixes #7043

Two slightly different custom routines were implemented by hand in
dtostrf (an AVR-lib non-ISO function) and Print. This resulted in
inconsistent output of float/double vars when rounding was needed.

Replace them all with a call to sprintf(), removing the duplicated, not
quite correct code.

Print(String(float)) and Print(float) now generate the same output.

Fixes esp8266#7043

Two slightly different custom routines were implemented by hand in
dtostrf (an AVR-lib non-ISO function) and Print.  This resulted in
inconsistent output of float/double vars when rounding was needed.

Replace them all with a call to sprintf(), removing the duplicated, not
quite correct code.

Print(String(float)) and Print(float) now generate the same output.
@earlephilhower

Copy link
Copy Markdown
Collaborator Author

@devyte devyte added this to the 2.7.0 milestone Feb 9, 2020
@earlephilhower earlephilhower merged commit 11ae243 into esp8266:master Feb 10, 2020

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, crap. Thank you for reminding me about that! I had a niggle about it, but it's been maybe 2 years since the whole -u print_float stuff.

I'll open a new issue. The solution is not clear to me now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Rounding Values when Using String Type Cast

3 participants