Struct comlib_math::ModInt [−][src]
pub struct ModInt<M: Modulus>(_, _);Expand description
Integer type for which all computations are executed in modulo given by M::modulus.
Examples
let p = RuntimePrimeModulus::from(5u8);
let a = ModInt::from((7, p));
assert_eq!(a, ModInt::from((2, p)));
let b = ModInt::from((3, p));
assert_eq!(*(a + b), 0);
assert_eq!(*(a * b), 1);
assert_eq!(*(b - a), 1);
assert_eq!(*(a - b), 4);
assert_eq!(*(a / b), 4);Implementations
Computes the inverse of the value.
Returns the inner value without the modulus.
Always in the range [0, self.modulus()).
Trait Implementations
Performs the += operation. Read more
Performs the /= operation. Read more
Performs the *= operation. Read more
Performs the -= operation. Read more
Auto Trait Implementations
impl<M> RefUnwindSafe for ModInt<M> where
M: RefUnwindSafe,
<M as Modulus>::Base: RefUnwindSafe,
impl<M> UnwindSafe for ModInt<M> where
M: UnwindSafe,
<M as Modulus>::Base: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more