You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Return integer ratio.
Return a pair of integers, whose ratio is exactly equal to the original int
and with a positive denominator.
Fraction:
as_integer_ratio(self)
Return the integer ratio as a tuple.
Return a tuple of two integers, whose ratio is equal to the
Fraction and with a positive denominator.
float:
Return integer ratio.
Return a pair of integers, whose ratio is exactly equal to the original float
and with a positive denominator.
Decimal:
Return a pair of integers, whose ratio is exactly equal to the original
Decimal and with a positive denominator. The ratio is in lowest terms.
Raise OverflowError on infinities and a ValueError on NaNs.
All methods actually return a pair, whose ratio is in lowest terms, but only the last docstring says this explicitly. Shouldn't other methods do same? (Taken from this.)
Edit: Ditto for some sphinx docs, e.g. for the float.as_integer_ratio(): "Return a pair of integers whose ratio is exactly equal to the original float and with a positive denominator. Raises OverflowError on infinities and a ValueError on NaNs."
Activity
pythongh-101825: mention, that as_integer_ratio() output is normalized
pythongh-101825: mention, that as_integer_ratio() output is normalized
gh-101825: Clarify that as_integer_ratio() output is always normalized (
mdickinson commentedon Feb 27, 2023
Closed in #101843.
Merge branch 'main' into inlinecomp2