diff --git a/fixed_wide/src/fixed.rs b/fixed_wide/src/fixed.rs index 0833068..e1cf4a8 100644 --- a/fixed_wide/src/fixed.rs +++ b/fixed_wide/src/fixed.rs @@ -178,6 +178,7 @@ macro_rules! impl_multiply_operator_not_const_generic { } } } + #[cfg(not(feature="wide-mul"))] impl_multiplicative_operator_not_const_generic!(($struct, $trait, $method, $output ), $width); } } @@ -194,6 +195,7 @@ macro_rules! impl_divide_operator_not_const_generic { } } } + #[cfg(not(feature="wide-mul"))] impl_multiplicative_operator_not_const_generic!(($struct, $trait, $method, $output ), $width); }; } @@ -279,6 +281,19 @@ impl_shift_operator!( Fixed, Shl, shl, Self ); impl_shift_assign_operator!( Fixed, ShrAssign, shr_assign ); impl_shift_operator!( Fixed, Shr, shr, Self ); +macro_rules! impl_wide_operators{ + ($lhs:expr,$rhs:expr)=>{ + impl core::ops::Mul> for Fixed<$lhs,{$lhs*32}>{ + type Output=Fixed<{$lhs+$rhs},{($lhs+$rhs)*32}>; + fn mul(self, other: Fixed<$rhs,{$rhs*32}>)->Self::Output{ + paste::item!{ + self.[](other) + } + } + } + } +} + // WIDE MUL: multiply into a wider type // let a = I32F32::ONE; // let b:I64F64 = a.wide_mul(a); @@ -306,6 +321,8 @@ macro_rules! impl_wide_not_const_generic{ } } } + #[cfg(feature="wide-mul")] + impl_wide_operators!($lhs,$rhs); }; }