diff --git a/agb/src/number.rs b/agb/src/number.rs index d5229703..14c49e5a 100644 --- a/agb/src/number.rs +++ b/agb/src/number.rs @@ -41,42 +41,26 @@ impl SubAssign for Num { impl Mul for Num { type Output = Self; fn mul(self, rhs: Num) -> Self::Output { - if N % 2 == 0 { - Num((self.0 >> (N / 2)) * (rhs.0 >> (N / 2))) - } else { - Num((self.0 >> (1 + N / 2)) * (rhs.0 >> (N / 2))) - } + Num((self.0 * rhs.0) >> N) } } impl MulAssign for Num { fn mul_assign(&mut self, rhs: Self) { - if N % 2 == 0 { - self.0 = (self.0 >> (N / 2)) * (rhs.0 >> (N / 2)) - } else { - self.0 = (self.0 >> (1 + N / 2)) * (rhs.0 >> (N / 2)) - } + self.0 = (*self * rhs).0 } } impl Div for Num { type Output = Self; fn div(self, rhs: Num) -> Self::Output { - if N % 2 == 0 { - Num((self.0 << (N / 2)) / (rhs.0 >> (N / 2))) - } else { - Num((self.0 << (1 + N / 2)) / (rhs.0 >> (N / 2))) - } + Num((self.0 << N) / rhs.0) } } impl DivAssign for Num { fn div_assign(&mut self, rhs: Self) { - if N % 2 == 0 { - self.0 = (self.0 << (N / 2)) / (rhs.0 >> (N / 2)) - } else { - self.0 = (self.0 << (1 + N / 2)) / (rhs.0 >> (N / 2)) - } + self.0 = (*self / rhs).0 } }