Refactoring
This commit is contained in:
parent
b44908429a
commit
1f96d76c74
@ -427,35 +427,32 @@ impl Ord for Number {
|
|||||||
} else if self.sign == Sign::Positif && other.sign == Sign::Negatif {
|
} else if self.sign == Sign::Positif && other.sign == Sign::Negatif {
|
||||||
return Ordering::Greater;
|
return Ordering::Greater;
|
||||||
}
|
}
|
||||||
if self.digits.len() < other.digits.len() {
|
match self.digits.len().cmp(&other.digits.len()) {
|
||||||
if self.sign == Sign::Positif {
|
Ordering::Less => match self.sign {
|
||||||
return Ordering::Less;
|
Sign::Positif => Ordering::Less,
|
||||||
} else if self.sign == Sign::Negatif {
|
Sign::Negatif => Ordering::Greater,
|
||||||
return Ordering::Greater;
|
},
|
||||||
}
|
Ordering::Greater => match self.sign {
|
||||||
} else if self.digits.len() > other.digits.len() {
|
Sign::Positif => Ordering::Greater,
|
||||||
if self.sign == Sign::Positif {
|
Sign::Negatif => Ordering::Less,
|
||||||
return Ordering::Greater;
|
},
|
||||||
} else if self.sign == Sign::Negatif {
|
Ordering::Equal => {
|
||||||
return Ordering::Less;
|
for pair in zip(&self.digits, &other.digits) {
|
||||||
|
return match pair.0.cmp(pair.1) {
|
||||||
|
Ordering::Less => match self.sign {
|
||||||
|
Sign::Positif => Ordering::Less,
|
||||||
|
Sign::Negatif => Ordering::Greater,
|
||||||
|
},
|
||||||
|
Ordering::Greater => match self.sign {
|
||||||
|
Sign::Positif => Ordering::Greater,
|
||||||
|
Sign::Negatif => Ordering::Less,
|
||||||
|
},
|
||||||
|
Ordering::Equal => continue,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
Ordering::Equal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for pair in zip(&self.digits, &other.digits) {
|
|
||||||
if pair.0 < pair.1 {
|
|
||||||
if self.sign == Sign::Positif {
|
|
||||||
return Ordering::Less;
|
|
||||||
} else if self.sign == Sign::Negatif {
|
|
||||||
return Ordering::Greater;
|
|
||||||
}
|
|
||||||
} else if pair.0 > pair.1 {
|
|
||||||
if self.sign == Sign::Positif {
|
|
||||||
return Ordering::Greater;
|
|
||||||
} else if self.sign == Sign::Negatif {
|
|
||||||
return Ordering::Less;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Ordering::Equal
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user