From 17d43852d316261209f60407111f063b07621924 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 27 Aug 2024 13:20:17 -0700 Subject: [PATCH] wip: partial cmp --- deferred_division/src/wide.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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>