Be a little bit more careful about what items we do and don't include, start adding modular math into the system.

This commit is contained in:
2018-10-02 13:37:39 -07:00
parent 19a298e56c
commit 3678ffdd6c
398 changed files with 1215625 additions and 1243369 deletions

16
src/unsigned/modmul.rs Normal file
View File

@@ -0,0 +1,16 @@
pub trait ModMul<T> {
fn modmul(&self, x: &Self, m: &T) -> Self;
}
macro_rules! modmul_impls {
($name: ident, $dbl: ident) => {
impl ModMul<$name> for $name {
fn modmul(&self, x: &$name, m: &$name) -> $name {
let mulres = (self as &$name) * x;
let bigm = $dbl::from(m);
let (_, bigres) = mulres.divmod(&bigm);
$name::from(bigres)
}
}
};
}