use crate::integer::Integer;
use core::cmp::Ordering;
use malachite_base::num::arithmetic::traits::UnsignedAbs;
macro_rules! impl_float {
($t: ident) => {
impl PartialOrd<$t> for Integer {
fn partial_cmp(&self, other: &$t) -> Option<Ordering> {
if self.sign {
self.unsigned_abs().partial_cmp(other)
} else {
self.unsigned_abs()
.partial_cmp(&-other)
.map(Ordering::reverse)
}
}
}
impl PartialOrd<Integer> for $t {
#[inline]
fn partial_cmp(&self, other: &Integer) -> Option<Ordering> {
other.partial_cmp(self).map(Ordering::reverse)
}
}
};
}
apply_to_primitive_floats!(impl_float);