mirror of
https://github.com/powdr-labs/powdr.git
synced 2026-05-13 03:00:26 -04:00
Merge pull request #1056 from powdr-labs/ff-better-error-message
Improve error message in `std::math::ff:inverse`
This commit is contained in:
@@ -2,7 +2,11 @@
|
||||
/// Assumes that `modulus` is prime, but does not check it.
|
||||
let inverse = |x, modulus|
|
||||
if x <= 0 || x >= modulus {
|
||||
std::check::panic("Tried to compute the inverse of zero, of a negative number or a number outside the field.")
|
||||
if x == 0 {
|
||||
std::check::panic("Tried to compute the inverse of zero.")
|
||||
} else {
|
||||
std::check::panic("Tried to compute the inverse of a negative number or a number outside the field.")
|
||||
}
|
||||
} else {
|
||||
reduce(extended_gcd(x, modulus)[0], modulus)
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user