-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
fixed the overflow problem of powermod(x::Integer, p::Integer, m::T) #48192
Conversation
This isn't a great solution since it is type unstable and probably pretty slow. A better approach would probably be to compute |
I don't really see the type stability issue. |
Good point. I forgot that the type of the exponent of |
@oscardssmith @KristofferC Thanks! Maybe the BigInt can work, but I still think the fast exponentiation has higher performance and is more "elegant". I will revise it |
@@ -267,6 +267,9 @@ end | |||
@test powermod(2, -2, 5) == 4 | |||
@test powermod(2, -1, -5) == -2 | |||
@test powermod(2, -2, -5) == -1 | |||
|
|||
@test powermod(2, typemin(Int128), 5) == 1 | |||
@test powermod(2, typemin(Int128), -5) == -4 |
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.
add a test for BigInt
power to make sure this still works for types without typemin
.
Co-authored-by: Oscar Smith <oscardssmith@gmail.com>
Thanks for the PR! |
Fixed #48166