mirror of
https://github.com/python/cpython.git
synced 2025-09-02 15:07:53 +00:00
gh-100488: Add is_integer method to fractions.Fraction (#100489)
This commit is contained in:
parent
71159a8e07
commit
e83f88a455
4 changed files with 24 additions and 0 deletions
|
@ -225,6 +225,10 @@ class Fraction(numbers.Rational):
|
|||
(cls.__name__, dec, type(dec).__name__))
|
||||
return cls(*dec.as_integer_ratio())
|
||||
|
||||
def is_integer(self):
|
||||
"""Return True if the Fraction is an integer."""
|
||||
return self._denominator == 1
|
||||
|
||||
def as_integer_ratio(self):
|
||||
"""Return the integer ratio as a tuple.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue