simplify > < etc in fraction
This commit is contained in:
parent
2e80eabb33
commit
43973a0039
@ -197,17 +197,19 @@ class Fraction(object):
|
|||||||
|
|
||||||
def __lt__(self, other):
|
def __lt__(self, other):
|
||||||
""" < """
|
""" < """
|
||||||
if type(other) == Fraction:
|
return float(self) < float(other)
|
||||||
return (self._num / self._denom) < (other._num / other._denom)
|
|
||||||
else:
|
|
||||||
return (self._num / self._denom) < other
|
|
||||||
|
|
||||||
def __le__(self, other):
|
def __le__(self, other):
|
||||||
""" <= """
|
""" <= """
|
||||||
if type(other) == Fraction:
|
return float(self) <= float(other)
|
||||||
return (self._num / self._denom) <= (other._num / other._denom)
|
|
||||||
else:
|
def __gt__(self, other):
|
||||||
return (self._num / self._denom) <= other
|
""" > """
|
||||||
|
return float(self) > float(other)
|
||||||
|
|
||||||
|
def __ge__(self, other):
|
||||||
|
""" >= """
|
||||||
|
return float(self) >= float(other)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user