diff --git a/fixed_wide/src/fixed.rs b/fixed_wide/src/fixed.rs index a566151..05e8b26 100644 --- a/fixed_wide/src/fixed.rs +++ b/fixed_wide/src/fixed.rs @@ -295,10 +295,14 @@ macro_rules! impl_multiply_operator_not_const_generic { impl $struct<$width,F>{ paste::item!{ #[inline] - pub fn [](self, other: Self) -> Self { - let lhs=self.bits.as_::>(); - let rhs=other.bits.as_::>(); - Self::from_bits(lhs.mul(rhs).shr(F as u32).as_()) + pub fn [](self, rhs: Self) -> Self { + let (low,high)=self.bits.unsigned_abs().widening_mul(rhs.bits.unsigned_abs()); + let out:BInt::<{$width*2}>=unsafe{core::mem::transmute([low,high])}; + if self.is_negative()==rhs.is_negative(){ + Self::from_bits(out.shr(F as u32).as_()) + }else{ + -Self::from_bits(out.shr(F as u32).as_()) + } } } }