This commit is contained in:
Quaternions 2024-08-27 13:28:53 -07:00
parent a097e3945f
commit 626eb7e9e2

View File

@ -14,3 +14,32 @@ pub trait WideCross<Rhs=Self>{
type Output; type Output;
fn wide_cross(self,rhs:Rhs)->Self::Output; fn wide_cross(self,rhs:Rhs)->Self::Output;
} }
struct Ratio<Num,Den>{
num:Num,
den:Den,
}
impl<Num,Den,T> WideMul<T> for Ratio<Num,Den>
where
Num:WideMul<T>,
{
type Output=Ratio<<Num as WideMul<T>>::Output,Den>;
fn wide_mul(self,rhs:T)->Ratio<<Num as WideMul<T>>::Output,Den>{
Ratio{
num:self.num.wide_mul(rhs),
den:self.den,
}
}
}
impl<Num,Den,T> WideDiv<T> for Ratio<Num,Den>
where
Den:WideMul<T>,
{
type Output=Ratio<Num,<Den as WideMul<T>>::Output>;
fn wide_div(self,rhs:T)->Ratio<Num,<Den as WideMul<T>>::Output>{
Ratio{
num:self.num,
den:self.den.wide_mul(rhs),
}
}
}