-
Notifications
You must be signed in to change notification settings - Fork 3k
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
minimal-printf doesn't display decimals between -1 to 0 correctly #13783
Comments
Thank you for raising this detailed GitHub issue. I am now notifying our internal issue triagers. |
This issue is also affecting me. I'm having to duplicate print calls for negative and positive cases to deal with this. Target(s) affected by this defect ? Toolchain(s) (name and version) displaying this defect ? What version of Mbed-os are you using (tag or sha) ? What version(s) of tools are you using. List all that apply (E.g. mbed-cli) Additional details
This works fine as long as negative values are less than or equal to -1.0. Otherwise, for values between 0.0 and -1.0, the integer component is "-0", which loses the sign when being saved in a signed integer format. Again, for the sake of clarity, writing a floating point value to a signed integer results in loss of sign information if the value in question is between 0.0 and 1.0. Suggested solution
Insert this code:
That will add the sign character in this scenario, without interfering with the existing method of printing. |
Thanks @helpfulchicken . I commented in the #13784 (fix for this), if we should consider your fix. |
Description of defect
The output of:
with minimal-printf is:
d = 0.001391
but it should be:
d = -0.001391
with setting "target.printf_lib": "std" the output is as expected.
Target(s) affected by this defect ?
NUCLEO_F413ZH
Toolchain(s) (name and version) displaying this defect ?
gcc-arm-none-eabi-9-2019-q4-major
What version of Mbed-os are you using (tag or sha) ?
mbed-os-6.3.0
What version(s) of tools are you using. List all that apply (E.g. mbed-cli)
mbed-cli
How is this defect reproduced ?
The text was updated successfully, but these errors were encountered: