-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Float conversion with dynamic scaling #263
Conversation
Complete rework of the floating point conversion code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, and the size tests don't lie :)
I left feedback about updating the comment; please also update the readme.md to take credit for your work, and also to explain it! :)
I will add commits for the documentation and more detailed comments later, when the code will be in it's final state. Also I will add new tests in https://en.cppreference.com/w/c/language/_Static_assert Another open question is what integer widths the unit tests should test. For now I set it to 32-bit, but probably it's worth considering some tests for 64-bit and maybe even 16/8-bit tests at least for a single platform. Actually I added the same compiler warnings to my local setup and for 8-bit integers the Also some C++ tests on Clang failed with this:
https://en.cppreference.com/w/cpp/types/NULL |
Re: Re: clang yelling about Re: Re: tests- I don't mind the build getting bigger / more complex if it means more test coverage! Maybe a separate nested loop in the cmake test file that runs the same tests with 8/16/32, and at test runtime uses define flags to figure out when to stop (i.e. so we don't run 32-bit width tests in the 8-bit config?) |
Oh neat, look at that! https://en.cppreference.com/w/c/language/nullptr Well, when it's time to move npf to C23, I'll delete the clang-suppression warning :) |
Here is a patch for paland.cc: float32.patch Another potential minor issue is that both the current release and this rework prints the sign for NAN and OOR outputs. Though for OOR it somewhat even makes sense in a similar way as for INF. |
I applied the patch to a remote branch named |
As all of the current checks are passing, now I will create some useful unit tests for the new |
Exciting! The difference between
|
By the way, all of the currents tests run on platforms, where the size of I went further and already created tests for all integer widths. I used the Any comments on the newly added unit tests? |
I think it all looks excellent, thanks again for the amazing work. Please credit yourself in the code (maybe with an algo description?) and in the readme- this is a huge effort and your name should be all over it :) As soon as you're ready to promote the PR out of draft, I'll happily approve! |
BTW if you like, I keep meaning to move npf to C++20 for the test stuff. If you want to move it up in this PR, that's cool, otherwise I'll do it separately soon. |
Hi @Okarss! Just checking in and saying hi. How is this PR coming? I'm very excited to merge it! No rush or anything; npf has no need to move quickly or with urgency at this point, but your PR is tantalizing and such an improvement that I'd love to get it in, so I'm curious :) |
Hi! I do completely understand your excitement and actually I myself am pretty intrigued. I pushed an updated documentation. Actually it would be nice if you can check and correct the grammatical and style errors, as obviously English is not my first language. :) I guess there is no need for C++20 right now and we can update to it later. One more minor issue I noticed. As this PR removes the range limits, the message "oor" (out of range) doesn't seem appropriate anymore. Now only the buffer size can cause a non-standard error situation. Maybe that message should be changed to for example "buf" or even a generic "err"? |
Your English is apparently better than mine; thank you for the grammar fixes! I always forget to hyphenate adjective clauses. :) I agree that The PR otherwise looks great. Feel free to open it whenever you're ready! |
The |
I've just merged your branch over in paland-conformance to main, so you should be all set for retargeting! |
In addition I improved the algorithm explanation - it is more appropriate and easier to understand now. If necessary, I can also merge the changes from |
I have the branch protections set to require that the PR branch be up-to-date with the main branch, so that the tests that run cover what "main will become" if the PR merges. I clicked the "update branch" button on your behalf :) |
So, from my side everything is done. Or is there something else left to do? Funny moment... I guess for this topic, the By the way, now I have a few more ideas how to decrease the code size for other parts of the code. :D But, of course, those will not be as drastic as this one... |
🥳 Thanks again for such a high-quality and novel code. It's awesome. I would absolutely love to hear any ideas you have about the code footprint; I think at this point that you're probably as knowledgable of the npf internals as anyone 😄 Let's talk about it over in discussions, or if you want to open a new issue to talk it over, or whatever! |
This is a complete rewrite of the floating point code, which introduces the improvements discussed in #221 and #223. The main new features:
double
type directly instead of converting it tofloat
.