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

Partially fix printf hex float numbers/%a rounding #1286

Conversation

GabrielRavier
Copy link
Collaborator

Hexadecimal printing of floating-point numbers on cosmopolitan (that is,
using the a conversion specifier) currently does not correctly round the
result in any rounding mode except for the default one (i.e. FE_NEAREST)

This commit fixes this, and adds tests for the change (note that there's
still some rounding issues with the a conversion specifier in general in
relatively rare cases (that is, without non-default rounding modes), but
this author gave up on fixing them after they tried to read the floating
point formatting code, and wounded up almost more confused than before).

Hexadecimal printing of floating-point numbers on cosmopolitan (that is,
using the a conversion specifier) currently does not correctly round the
result in any rounding mode except for the default one (i.e. FE_NEAREST)

This commit fixes this, and adds tests for the change (note that there's
still some rounding issues with the a conversion specifier in general in
relatively rare cases (that is, without non-default rounding modes), but
this author gave up on fixing them after they tried to read the floating
point formatting code, and wounded up almost more confused than before).
@github-actions github-actions bot added the libc label Sep 10, 2024
Copy link
Owner

@jart jart left a comment

Choose a reason for hiding this comment

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

Thank you for doing this. That floating point code was inherited from Lucent. I wouldn't have been able to implement __fmt() without their help, but their code has always been ugly, and it used to fail a lot more things. Since adopting it, I've made it even uglier by smishing and smashing it into passing more tests. My dream is one day I'll get good enough at floating point code to rewrite it all. But that day is not today.

@jart jart merged commit 4d05060 into jart:master Sep 11, 2024
6 checks passed
@jart
Copy link
Owner

jart commented Sep 11, 2024

Commit message edited to communicate the improvement rather than the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants