mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
gh-101825: Clarify that as_integer_ratio() output is always normalized (#101843)
Make docstrings for `as_integer_ratio` consistent across types, and document that the returned pair is always normalized (coprime integers, with positive denominator). --------- Co-authored-by: Owain Davies <116417456+OTheDev@users.noreply.github.com> Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
This commit is contained in:
parent
4f3786b761
commit
4624987b29
7 changed files with 21 additions and 27 deletions
|
@ -1546,12 +1546,10 @@ float_fromhex(PyTypeObject *type, PyObject *string)
|
|||
/*[clinic input]
|
||||
float.as_integer_ratio
|
||||
|
||||
Return integer ratio.
|
||||
Return a pair of integers, whose ratio is exactly equal to the original float.
|
||||
|
||||
Return a pair of integers, whose ratio is exactly equal to the original float
|
||||
and with a positive denominator.
|
||||
|
||||
Raise OverflowError on infinities and a ValueError on NaNs.
|
||||
The ratio is in lowest terms and has a positive denominator. Raise
|
||||
OverflowError on infinities and a ValueError on NaNs.
|
||||
|
||||
>>> (10.0).as_integer_ratio()
|
||||
(10, 1)
|
||||
|
@ -1563,7 +1561,7 @@ Raise OverflowError on infinities and a ValueError on NaNs.
|
|||
|
||||
static PyObject *
|
||||
float_as_integer_ratio_impl(PyObject *self)
|
||||
/*[clinic end generated code: output=65f25f0d8d30a712 input=e21d08b4630c2e44]*/
|
||||
/*[clinic end generated code: output=65f25f0d8d30a712 input=d5ba7765655d75bd]*/
|
||||
{
|
||||
double self_double;
|
||||
double float_part;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue