minimal-printf: fix display decimals between -1 to 0 incorrect issue #13865
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of changes
Fixes "minimal-printf doesn't display decimals between -1 to 0 correctly" listed in #13783
In original mbed_minimal_formatted_string_signed(), the type of augment value is a signed integer. Given a double value -0.00139 being printed, its integer part is 0 (-0 is equal to 0), so the condition "if (value < 0)" is false and it was handled as a positive decimal like 0.00139. In the fix, the value is a double type. Given a double value -0.00139, the condition "if (value < (double)0)" is true and it is handled as a negative decimal as expected.
Impact of changes
Migration actions required
Documentation
Pull request type
Test results
double d = -0.00139;
printf("d = %f\r\n",d);
--->
d = -0.001391
Reviewers