summaryrefslogtreecommitdiff
path: root/Objects/floatobject.c
diff options
context:
space:
mode:
authorSergey B Kirpichev <skirpichev@gmail.com>2023-02-27 22:11:28 +0300
committerGitHub <noreply@github.com>2023-02-27 19:11:28 +0000
commit4624987b296108c2dc1e6e3a24e65d2de7afd451 (patch)
tree0a490563b4c31f14740e72ce6b3ef0c0c1a3e2e8 /Objects/floatobject.c
parent4f3786b7616dd464242b88ad6914053d409fe9d2 (diff)
downloadcpython-git-4624987b296108c2dc1e6e3a24e65d2de7afd451.tar.gz
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>
Diffstat (limited to 'Objects/floatobject.c')
-rw-r--r--Objects/floatobject.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
index 912b742f79..d641311f11 100644
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -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;