div_euclid
This commit is contained in:
parent
a274b6d232
commit
c5fb915a6d
@ -412,7 +412,7 @@ macro_rules! impl_multiply_operator_not_const_generic {
|
|||||||
type Output=Self;
|
type Output=Self;
|
||||||
#[inline]
|
#[inline]
|
||||||
fn divide(self, other: i64)->Self::Output{
|
fn divide(self, other: i64)->Self::Output{
|
||||||
Self::from_bits(self.bits/BInt::from(other))
|
Self::from_bits(self.bits.div_euclid(BInt::from(other)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -426,7 +426,7 @@ macro_rules! impl_divide_operator_not_const_generic {
|
|||||||
//this only needs to be $width+F as u32/64+1 but MUH CONST GENERICS!!!!!
|
//this only needs to be $width+F as u32/64+1 but MUH CONST GENERICS!!!!!
|
||||||
let lhs=self.bits.as_::<BInt::<{$width*2}>>().shl(F as u32);
|
let lhs=self.bits.as_::<BInt::<{$width*2}>>().shl(F as u32);
|
||||||
let rhs=other.bits.as_::<BInt::<{$width*2}>>();
|
let rhs=other.bits.as_::<BInt::<{$width*2}>>();
|
||||||
Self::from_bits(lhs.div(rhs).as_())
|
Self::from_bits(lhs.div_euclid(rhs).as_())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -446,7 +446,7 @@ macro_rules! impl_divide_operator_not_const_generic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! impl_multiplicative_operator {
|
macro_rules! impl_multiplicative_operator {
|
||||||
( $struct: ident, $trait: ident, $method: ident, $output: ty ) => {
|
( $struct: ident, $trait: ident, $method: ident, $inner_method: ident, $output: ty ) => {
|
||||||
impl<const N:usize,const F:usize,U> core::ops::$trait<U> for $struct<N,F>
|
impl<const N:usize,const F:usize,U> core::ops::$trait<U> for $struct<N,F>
|
||||||
where
|
where
|
||||||
BInt::<N>:From<U>+core::ops::$trait,
|
BInt::<N>:From<U>+core::ops::$trait,
|
||||||
@ -454,20 +454,20 @@ macro_rules! impl_multiplicative_operator {
|
|||||||
type Output = $output;
|
type Output = $output;
|
||||||
#[inline]
|
#[inline]
|
||||||
fn $method(self,other:U)->Self::Output{
|
fn $method(self,other:U)->Self::Output{
|
||||||
Self::from_bits(self.bits.$method(BInt::<N>::from(other)))
|
Self::from_bits(self.bits.$inner_method(BInt::<N>::from(other)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
macro_rules! impl_multiplicative_assign_operator {
|
macro_rules! impl_multiplicative_assign_operator {
|
||||||
( $struct: ident, $trait: ident, $method: ident ) => {
|
( $struct: ident, $trait: ident, $method: ident, $not_assign_method: ident ) => {
|
||||||
impl<const N:usize,const F:usize,U> core::ops::$trait<U> for $struct<N,F>
|
impl<const N:usize,const F:usize,U> core::ops::$trait<U> for $struct<N,F>
|
||||||
where
|
where
|
||||||
BInt::<N>:From<U>+core::ops::$trait,
|
BInt::<N>:From<U>+core::ops::$trait,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn $method(&mut self,other:U){
|
fn $method(&mut self,other:U){
|
||||||
self.bits.$method(BInt::<N>::from(other));
|
self.bits=self.bits.$not_assign_method(BInt::<N>::from(other));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -495,10 +495,10 @@ macro_16!( impl_multiplicative_assign_operator_not_const_generic, (Fixed, MulAss
|
|||||||
macro_16!( impl_multiply_operator_not_const_generic, (Fixed, Mul, mul, Self) );
|
macro_16!( impl_multiply_operator_not_const_generic, (Fixed, Mul, mul, Self) );
|
||||||
macro_16!( impl_multiplicative_assign_operator_not_const_generic, (Fixed, DivAssign, div_assign, div) );
|
macro_16!( impl_multiplicative_assign_operator_not_const_generic, (Fixed, DivAssign, div_assign, div) );
|
||||||
macro_16!( impl_divide_operator_not_const_generic, (Fixed, Div, div, Self) );
|
macro_16!( impl_divide_operator_not_const_generic, (Fixed, Div, div, Self) );
|
||||||
impl_multiplicative_assign_operator!( Fixed, MulAssign, mul_assign );
|
impl_multiplicative_assign_operator!( Fixed, MulAssign, mul_assign, mul );
|
||||||
impl_multiplicative_operator!( Fixed, Mul, mul, Self );
|
impl_multiplicative_operator!( Fixed, Mul, mul, mul, Self );
|
||||||
impl_multiplicative_assign_operator!( Fixed, DivAssign, div_assign );
|
impl_multiplicative_assign_operator!( Fixed, DivAssign, div_assign, div_euclid );
|
||||||
impl_multiplicative_operator!( Fixed, Div, div, Self );
|
impl_multiplicative_operator!( Fixed, Div, div, div_euclid, Self );
|
||||||
#[cfg(feature="deferred-division")]
|
#[cfg(feature="deferred-division")]
|
||||||
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>{
|
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=ratio_ops::ratio::Ratio<Fixed<LHS_N,LHS_F>,Fixed<RHS_N,RHS_F>>;
|
type Output=ratio_ops::ratio::Ratio<Fixed<LHS_N,LHS_F>,Fixed<RHS_N,RHS_F>>;
|
||||||
|
Loading…
Reference in New Issue
Block a user