Skip to main content

ModularArithmetic

Trait ModularArithmetic 

Source
pub trait ModularArithmetic {
    // Required methods
    fn mod_add(&self, rhs: &Self, modulus: &Self) -> Self;
    fn mod_sub(&self, rhs: &Self, modulus: &Self) -> Self;
    fn mod_mul(&self, rhs: &Self, modulus: &Self) -> Self;
    fn mod_pow(&self, exp: &Self, modulus: &Self) -> Self;
}
Expand description

Modular arithmetic operations.

Required Methods§

Source

fn mod_add(&self, rhs: &Self, modulus: &Self) -> Self

Computes (self + rhs) mod modulus.

Source

fn mod_sub(&self, rhs: &Self, modulus: &Self) -> Self

Computes (self - rhs) mod modulus.

Source

fn mod_mul(&self, rhs: &Self, modulus: &Self) -> Self

Computes (self * rhs) mod modulus.

Source

fn mod_pow(&self, exp: &Self, modulus: &Self) -> Self

Computes self^exp mod modulus via binary exponentiation.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§