From 626eb7e9e2f6e28b357388814588e9829fb750b3 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 27 Aug 2024 13:28:53 -0700 Subject: [PATCH] ratio --- fixed_wide_traits/src/wide.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/fixed_wide_traits/src/wide.rs b/fixed_wide_traits/src/wide.rs index dfb7b15..f27085d 100644 --- a/fixed_wide_traits/src/wide.rs +++ b/fixed_wide_traits/src/wide.rs @@ -14,3 +14,32 @@ pub trait WideCross{ type Output; fn wide_cross(self,rhs:Rhs)->Self::Output; } + +struct Ratio{ + num:Num, + den:Den, +} +impl WideMul for Ratio + where + Num:WideMul, +{ + type Output=Ratio<>::Output,Den>; + fn wide_mul(self,rhs:T)->Ratio<>::Output,Den>{ + Ratio{ + num:self.num.wide_mul(rhs), + den:self.den, + } + } +} +impl WideDiv for Ratio + where + Den:WideMul, +{ + type Output=Ratio>::Output>; + fn wide_div(self,rhs:T)->Ratio>::Output>{ + Ratio{ + num:self.num, + den:self.den.wide_mul(rhs), + } + } +}