diff --git a/deferred_division/src/wide.rs b/deferred_division/src/wide.rs index df7dcae..f4c58a6 100644 --- a/deferred_division/src/wide.rs +++ b/deferred_division/src/wide.rs @@ -1,7 +1,19 @@ use std::ops::{Add,Mul}; +use std::cmp::Ordering; use crate::ratio::Ratio; use fixed_wide_traits::wide::{WideMul,WideDiv}; +impl PartialOrd for Ratio +{ + fn partial_cmp(&self,other:&T)->Option{ + //a < c*b + match self.den.cmp(0){ + Ordering::Less=>Some(self.num.partial_cmp(self.den.mul(other))), + Ordering::Equal=>None,//divide by zero + Ordering::Greater=>Some(self.num.partial_cmp(self.den.mul(other)).reverse()), + } + } +} impl Ratio { pub fn rational_add(self,rhs:T)->Ratio<>::Output>>::Output,Den>