Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

restore dtostrf when floats are disabled in printf/scanf + round fix#7093

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
devyte merged 7 commits intoesp8266:masterfromd-a-v:dtostrfix2
Feb 22, 2020

Conversation

@d-a-v
Copy link
Collaborator

@d-a-vd-a-v commentedFeb 19, 2020
edited
Loading

replaces andcloses#7087

(edit: tested)

fixes#7073 with solution 6
updates#7068
fixes#7043
(no need for-DNOPRINTFLOAT)

Copy link
Collaborator

@earlephilhowerearlephilhower left a comment

Choose a reason for hiding this comment

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

Looks like theif (function pointer) is not optimized. Both branches are present in all builds (float and non-float). That gives a 554-byte function in both cases. In normal mode, ~500 of those bytes are never used (the __dtostrf inlined code), and in non-float mode ~50 of those aren't used (the printf() branch).

I think this may be the best we can hope for, without adding a new#define like your original PR, so I'm approving as-is. If someone else has any ideas, I'd be interested...

d-a-v reacted with thumbs up emoji
@d-a-vd-a-v requested a review fromdevyteFebruary 20, 2020 06:21
@d-a-v
Copy link
CollaboratorAuthor

I am too interested in another solution because I see only the use of the define to not have the real implementation when printf-float is available. That's because the symbol presence cannot be known at compile time.

@earlephilhower with a patch to newlib, we could condition linking of_prinf_float the very same way we do with stack in sys space when WPS is not used. No more-u printf... nor any define. A simple call to a function could disable printf/floats at link time.

@earlephilhowerearlephilhower added this to the2.7.0 milestoneFeb 20, 2020
@d-a-v
Copy link
CollaboratorAuthor

diff from original dtostrf is

index b39edbb2..c742904d 100644--- a/cores/esp8266/core_esp8266_noniso.cpp+++ b/cores/esp8266/core_esp8266_noniso.cpp@@ -27,6 +27,7 @@ #include <stdbool.h> #include <stdint.h> #include <math.h>+#include <limits> #include "stdlib_noniso.h"  extern "C" {@@ -77,11 +78,15 @@ char * dtostrf(double number, signed char width, unsigned char prec, char *s) {     // Figure out how big our number really is     double tenpow = 1.0;     int digitcount = 1;-    while (number >= 10.0 * tenpow) {-        tenpow *= 10.0;+    double nextpow;+    while (number >= (nextpow = (10.0 * tenpow))) {+        tenpow = nextpow;         digitcount++;     } +    // minimal compensation for possible lack of precision (#7087 addition)+    number *= 1 + std::numeric_limits<decltype(number)>::epsilon();+     number /= tenpow;     fillme -= digitcount;

@devytedevyte merged commitcd56dc0 intoesp8266:masterFeb 22, 2020
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@earlephilhowerearlephilhowerearlephilhower approved these changes

@devytedevytedevyte approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

2.7.0

Development

Successfully merging this pull request may close these issues.

dtostrf/Print(float) inconsistent value/methods, downstream use [BUG]: Rounding Values when Using String Type Cast

3 participants

@d-a-v@earlephilhower@devyte

[8]ページ先頭

©2009-2025 Movatter.jp