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

"%g" makes incorrect decisions regarding switch from decimal to exponential #28

Closed
eyalroz opened this issue Aug 6, 2021 · 0 comments
Closed
Assignees
Labels
bug Something isn't working resolved-on-develop A changeset fixing this issue has been commiutted to the development branch

Comments

@eyalroz
Copy link
Owner

eyalroz commented Aug 6, 2021

If we printf_("%#.1g", -40661.5), we currently get -40662, but should be getting -4.e+04 because of the low precision: With "%g", the "precision" value means the number of significant digits to show; and if the number isn't fully captured by those, we are supposed to use exponential notation.

@eyalroz eyalroz added the bug Something isn't working label Aug 6, 2021
@eyalroz eyalroz self-assigned this Aug 6, 2021
eyalroz added a commit that referenced this issue Aug 7, 2021
eyalroz added a commit that referenced this issue Aug 7, 2021
* Rearranged `sprint_exponential_number`.
* Rewritten the exponential-vs-decimal choice logic for "%g".
* Fixed a latent bug: With precision 0, a decimal point is never printed, even if it should due to alternate mode (`%` flag).
* Some variable renaming for better clarity.
@eyalroz eyalroz added the resolved-on-develop A changeset fixing this issue has been commiutted to the development branch label Aug 7, 2021
@eyalroz eyalroz closed this as completed in c761a69 Aug 7, 2021
eyalroz added a commit that referenced this issue Sep 27, 2021
eyalroz added a commit that referenced this issue Sep 27, 2021
* Rearranged `sprint_exponential_number`.
* Rewritten the exponential-vs-decimal choice logic for "%g".
* Fixed a latent bug: With precision 0, a decimal point is never printed, even if it should due to alternate mode (`%` flag).
* Some variable renaming for better clarity.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working resolved-on-develop A changeset fixing this issue has been commiutted to the development branch
Projects
None yet
Development

No branches or pull requests

1 participant