ratio stuff

This commit is contained in:
Quaternions 2024-09-09 15:17:32 -07:00
parent 658c73a033
commit 3f0900b0ec

View File

@ -195,7 +195,7 @@ macro_rules! impl_divide_operator_not_const_generic {
} }
} }
} }
#[cfg(not(feature="wide-mul"))] #[cfg(all(not(feature="wide-mul"),not(feature="ratio")))]
impl_multiplicative_operator_not_const_generic!(($struct, $trait, $method, $output ), $width); impl_multiplicative_operator_not_const_generic!(($struct, $trait, $method, $output ), $width);
}; };
} }
@ -253,6 +253,13 @@ impl_multiplicative_assign_operator!( Fixed, MulAssign, mul_assign );
impl_multiplicative_operator!( Fixed, Mul, mul, Self ); impl_multiplicative_operator!( Fixed, Mul, mul, Self );
impl_multiplicative_assign_operator!( Fixed, DivAssign, div_assign ); impl_multiplicative_assign_operator!( Fixed, DivAssign, div_assign );
impl_multiplicative_operator!( Fixed, Div, div, Self ); impl_multiplicative_operator!( Fixed, Div, div, Self );
#[cfg(feature="ratio")]
impl<const LHS_N:usize,const LHS_F:usize,const RHS_N:usize,const RHS_F:usize> core::ops::Div<Fixed<RHS_N,RHS_F>> for Fixed<LHS_N,LHS_F>{
type Output=crate::ratio::Ratio<Fixed<LHS_N,LHS_F>,Fixed<RHS_N,RHS_F>>;
fn div(self, other: Fixed<RHS_N,RHS_F>)->Self::Output{
crate::ratio::Ratio::new(self,other)
}
}
// wide operators. The result width is the sum of the input widths, i.e. none of the multiplication // wide operators. The result width is the sum of the input widths, i.e. none of the multiplication