-
Notifications
You must be signed in to change notification settings - Fork 86
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
Support negative exponents in mul_2exp #458
Conversation
skirpichev
commented
Nov 28, 2023
•
edited
Loading
edited
- We try to convert to unsigned long (for mpfr_mul_2ui) and fallback to long on overflow (for mpfr_mul_2si), closes mul_2exp does not accept negative exponents #328
- Add GMPy_Integer_AsUnsignedLongOrLong() and adapt div_2exp() like above
- Return OverflowError in iroot(x,n) iff n>ULONG_MAX, closes TypeError in gmpy2.iroot #257
We try to convert to unsigned long (for mpfr_mul_2ui) and fallback to long on overflow (for mpfr_mul_2si). Closes aleaxit#328
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #458 +/- ##
==========================================
+ Coverage 85.05% 85.35% +0.29%
==========================================
Files 49 49
Lines 11733 11714 -19
Branches 2204 2204
==========================================
+ Hits 9980 9998 +18
+ Misses 1753 1716 -37 ☔ View full report in Codecov by Sentry. |
This does make sense for div_2exp() as well. But I'm thinking about some code reorganization first. Maybe it does make sense to add some |
That would make sense. We need to include 64-bit values on Windows where |
Is there any potential use cases besides |
Those would be the most common. Almost any code that relies on bit positions or bit length could use |
@casevh, I think this is ready for review.
I came to GMPy_Integer_AsUnsignedLongOrLong() helper function. GMP only has *_si/ui functions to work with signed/unsigned long. |
CI failures are unrelated to this pr. |
Agreed. Looks good. I'll merge it this weekend / when you tell me it is ready. |
@casevh, it was mentioned above, that this pr is ready for review. |
@casevh, I've added yet another (last, I think ;)) commit to this PR, which utilizes new function in iroot() (to raise OverflowError instead of ValueError's on overflow). |
Thanks. |