You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
z.ModInverse(g, n) immediately calls GCD(z, nil, g, n) but GCD says that the 3rd and 4th parameters must be > 0 so with g = -10, GCD sets the receiver to 0 and returns. z.ModInverse(10, -13) fails for the same reason.
We could set g = g mod n before the call to GCD in ModInverse to fix the first, but then the result wouldn't match the buildin % on native types.
dsnet
changed the title
math/big ModInverse doesn't support negative numbers
math/big: ModInverse doesn't support negative numbers
Sep 4, 2016
What version of Go are you using (
go version
)?go version go1.7rc3 linux/amd64
What operating system and processor architecture are you using (
go env
)?amd64
What did you do?
I tried computing inverse modulo of a negative number using this snippet:
What did you expect to see?
9
What did you see instead?
0
The text was updated successfully, but these errors were encountered: