From 548dd9ff673b4f4a119a92f4127ac47e3827aca6 Mon Sep 17 00:00:00 2001 From: Corwin Date: Sun, 8 Oct 2023 14:23:04 +0100 Subject: [PATCH] fix cos function --- agb-fixnum/src/lib.rs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/agb-fixnum/src/lib.rs b/agb-fixnum/src/lib.rs index ba20b183..19e5a704 100644 --- a/agb-fixnum/src/lib.rs +++ b/agb-fixnum/src/lib.rs @@ -533,17 +533,10 @@ impl Num { /// ``` #[must_use] pub fn cos(self) -> Self { - let one: Self = I::one().into(); let mut x = self; - let four: I = 4.into(); - let two: I = 2.into(); - let sixteen: I = 16.into(); - let nine: I = 9.into(); - let forty: I = 40.into(); - - x -= one / four + (x + one / four).floor(); - x *= (x.abs() - one / two) * sixteen; - x += x * (x.abs() - one) * (nine / forty); + x -= num!(0.25) + (x + num!(0.25)).floor(); + x *= (x.abs() - num!(0.5)) * num!(16.); + x += x * (x.abs() - num!(1.)) * num!(0.225); x }