Module malachite_base::num::arithmetic::mod_add
source · Expand description
ModAdd
and ModAddAssign
, traits for adding two
numbers modulo another number.
§mod_add
use malachite_base::num::arithmetic::traits::ModAdd;
assert_eq!(0u8.mod_add(3, 5), 3);
assert_eq!(7u32.mod_add(5, 10), 2);
§mod_add_assign
use malachite_base::num::arithmetic::traits::ModAddAssign;
let mut n = 0u8;
n.mod_add_assign(3, 5);
assert_eq!(n, 3);
let mut n = 7u32;
n.mod_add_assign(5, 10);
assert_eq!(n, 2);