From 900b594039c416b79045a56d55a7485f1141443f Mon Sep 17 00:00:00 2001 From: Corwin Kuiper Date: Sun, 6 Jun 2021 18:27:15 +0100 Subject: [PATCH] use easily optimisable division for truncate --- agb/src/number.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/agb/src/number.rs b/agb/src/number.rs index 13fbbdf8..c710b983 100644 --- a/agb/src/number.rs +++ b/agb/src/number.rs @@ -222,14 +222,7 @@ impl Num { } pub fn trunc(&self) -> I { - let fractional_part = self.0 & ((I::one() << N) - I::one()); - let self_as_int = self.0 >> N; - - if self_as_int < I::zero() && fractional_part != I::zero() { - self_as_int + I::one() - } else { - self_as_int - } + self.0 / (I::one() << N) } pub fn rem_euclid(&self, rhs: Self) -> Self {