Skip to content

Commit 9c54422

Browse files
committed
pythongh-101825: mention, that as_integer_ratio() output is normalized
1 parent dfc2e06 commit 9c54422

File tree

4 files changed

+9
-13
lines changed

4 files changed

+9
-13
lines changed

Doc/library/stdtypes.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ class`. In addition, it provides a few more methods:
602602

603603
.. method:: int.as_integer_ratio()
604604

605-
Return a pair of integers whose ratio is exactly equal to the original
605+
Return a pair of integers whose ratio is equal to the original
606606
integer and with a positive denominator. The integer ratio of integers
607607
(whole numbers) is always the integer as the numerator and ``1`` as the
608608
denominator.
@@ -624,7 +624,7 @@ class`. float also has the following additional methods.
624624
.. method:: float.as_integer_ratio()
625625

626626
Return a pair of integers whose ratio is exactly equal to the
627-
original float and with a positive denominator. Raises
627+
original float, is in lowest terms and with a positive denominator. Raises
628628
:exc:`OverflowError` on infinities and a :exc:`ValueError` on
629629
NaNs.
630630

Lib/fractions.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,9 @@ def is_integer(self):
320320
return self._denominator == 1
321321

322322
def as_integer_ratio(self):
323-
"""Return the integer ratio as a tuple.
323+
"""Return a pair of integers, whose ratio is equal to the original Fraction.
324324
325-
Return a tuple of two integers, whose ratio is equal to the
326-
Fraction and with a positive denominator.
325+
The ratio is in lowest terms and with a positive denominator.
327326
"""
328327
return (self._numerator, self._denominator)
329328

Objects/floatobject.c

+3-5
Original file line numberDiff line numberDiff line change
@@ -1546,12 +1546,10 @@ float_fromhex(PyTypeObject *type, PyObject *string)
15461546
/*[clinic input]
15471547
float.as_integer_ratio
15481548
1549-
Return integer ratio.
1549+
Return a pair of integers, whose ratio is exactly equal to the original float.
15501550
1551-
Return a pair of integers, whose ratio is exactly equal to the original float
1552-
and with a positive denominator.
1553-
1554-
Raise OverflowError on infinities and a ValueError on NaNs.
1551+
The ratio is in lowest terms and with a positive denominator. Raise
1552+
OverflowError on infinities and a ValueError on NaNs.
15551553
15561554
>>> (10.0).as_integer_ratio()
15571555
(10, 1)

Objects/longobject.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -6020,10 +6020,9 @@ int_bit_count_impl(PyObject *self)
60206020
/*[clinic input]
60216021
int.as_integer_ratio
60226022
6023-
Return integer ratio.
6023+
Return a pair of integers, whose ratio is equal to the original int.
60246024
6025-
Return a pair of integers, whose ratio is exactly equal to the original int
6026-
and with a positive denominator.
6025+
The ratio is in lowest terms and with a positive denominator.
60276026
60286027
>>> (10).as_integer_ratio()
60296028
(10, 1)

0 commit comments

Comments
 (0)