-
Notifications
You must be signed in to change notification settings - Fork 0
bid32_to_binary32 and binary32_to_bid32 #3
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
base: ieee-decimal
Are you sure you want to change the base?
Conversation
…nto ieee-decimal-conversions
|
This implementation was ported from https://www.intel.com/content/www/us/en/developer/articles/tool/intel-decimal-floating-point-math-library.html. Specifically, this is the bid32_to_binary32 implementation from bid_binarydecimal.c. Most of the other conversion methods in that file will also need to be ported. Reviews of this PR should have that implementation in mind. Notably, I have not tested this implementation yet. Any suggestions for how to properly test this appreciated. I'm not sure how portable the testing framework Intel provides is, and I don't know what we will be able to borrow from that. I'm probably going to work on binary32_to_bid32 next so we can at the very least have round trip tests. |
|
I added the reverse direction. I'm slightly concerned at the size of the code, especially given that we haven't touched larger types such as bid128 or binary64. I would also like to note that the more we rely on this intel implementation the less we can "copy paste" for implementing Decimal64 and Deicmal128. I imagine this will cause issues when we port things like Addition, because implementing it on all three types will no longer be "free" as we imagined it being. |
| bid_roundbound_128[((s & 1) << 1) + (int)(c_prov & 1)].Item2, // PORT: the calculation of this index factors in the rounding mode in the original code | ||
| bid_roundbound_128[((s & 1) << 1) + (int)(c_prov & 1)].Item1, | ||
| z.Item5, | ||
| z.Item4 |
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.
I will also generally note that porting this code can be very error prone. I happened to discover a typo I made last week in which this line was incorrectly z.Item3 instead of z.Item4. If I hadn't found it by chance, I am not sure how we would have ever found that bug. Even with exhaustive tests (which are still up in the air) I'd imagine debugging this code is a nightmare. We should keep this in mind when thinking about development cost.
I think I found what I was looking for in |
|
I added a couple passing test cases as examples. There are many more in the intel library that can eventually be manually ported with little difficulty. |

No description provided.