Skip to content
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

lib_libvsprintf: fix the float point print bug #7677

Merged
merged 1 commit into from
Nov 24, 2022

Conversation

flyingfish89
Copy link
Contributor

Summary

such as code: double value = +0x1.000000000000080000000000p-600;
printf("Hello, World!! %.7g:f64\n", value);
expected output : Hello, World!! 2.40992e-181:f64
but real output : Hello, World!! 2.40992e-B1:f64
the reason: we want printf "18", but the flag of character is 'B'
and 'B' is '0'+18,so printf 'B';

Related issue: #7620

Impact

float printf

Testing

esp32c3 with test code

double value = +0x1.000000000000080000000000p-600;
printf("Hello, World!! %.7g:f64\n", value);

@flyingfish89 flyingfish89 reopened this Nov 24, 2022
@flyingfish89 flyingfish89 force-pushed the modify_printf branch 4 times, most recently from e7a3c1e to b452d46 Compare November 24, 2022 09:51
@xiaoxiang781216 xiaoxiang781216 linked an issue Nov 24, 2022 that may be closed by this pull request
such as code: double value = +0x1.000000000000080000000000p-600;
              printf("Hello, World!! %.7g:f64\n", value);
expected output : Hello, World!! 2.40992e-181:f64
but real output : Hello, World!! 2.40992e-B1:f64
the reason: we want printf "18", but the flag of character is 'B'
            and 'B' is '0'+18,so printf 'B';
@no1wudi
Copy link
Contributor

no1wudi commented Nov 24, 2022

Verified on my local machine that this patch can fix #7620

@acassis acassis merged commit 4b87a8b into apache:master Nov 24, 2022
putc('0' + exp, stream);
/* Parse the ndigs if the value of it bigger than '9' */

while (1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe better to

Suggested change
while (1)
while (ndigits > 0)

Or something like this. Just from some static alalyzers point of view

@jerpelea jerpelea added this to To-Add in Release Notes - 12.0.0 Dec 29, 2022
@jerpelea jerpelea moved this from To-Add to Added in Release Notes - 12.0.0 Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

[Bug] Problem with print floating point
6 participants