diff --git a/agb-fixnum/src/lib.rs b/agb-fixnum/src/lib.rs index ea8d4adf..8b0d1b0c 100644 --- a/agb-fixnum/src/lib.rs +++ b/agb-fixnum/src/lib.rs @@ -133,7 +133,7 @@ macro_rules! upcast_multiply_impl { .wrapping_mul(b_frac) .wrapping_add(b_floor.wrapping_mul(a_frac)), ) - .wrapping_add(a_frac.wrapping_mul(b_frac) >> n) + .wrapping_add(((a_frac as u32).wrapping_mul(b_frac as u32) >> n) as $T) } }; ($T: ty, $Upcast: ty) => { @@ -1236,6 +1236,17 @@ mod tests { ); } + #[test] + fn check_16_bit_precision_i32() { + let a: Num = num!(1.923); + let b = num!(2.723); + + assert_eq!( + a * b, + Num::from_raw(((a.to_raw() as i64 * b.to_raw() as i64) >> 16) as i32) + ) + } + #[test] fn test_numbers() { // test addition