diff --git a/agb/src/number.rs b/agb/src/number.rs index 9590798a..c27401f9 100644 --- a/agb/src/number.rs +++ b/agb/src/number.rs @@ -1,6 +1,6 @@ use core::{ fmt::Display, - ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign}, + ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, RemAssign, Sub, SubAssign}, }; #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)] @@ -96,6 +96,25 @@ where } } +impl Rem for Num +where + T: Into>, +{ + type Output = Self; + fn rem(self, modulus: T) -> Self::Output { + Num(self.0 % modulus.into().0) + } +} + +impl RemAssign for Num +where + T: Into>, +{ + fn rem_assign(&mut self, modulus: T) { + self.0 = (*self % modulus).0 + } +} + impl Neg for Num { type Output = Self; fn neg(self) -> Self::Output { @@ -107,6 +126,7 @@ impl Num { pub fn max() -> Self { Num(i32::MAX) } + pub fn min() -> Self { Num(i32::MIN) }