]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-102823: Document return type of floor division on floats (GH-102824) (...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 8 Sep 2023 13:23:41 +0000 (06:23 -0700)
committerGitHub <noreply@github.com>
Fri, 8 Sep 2023 13:23:41 +0000 (15:23 +0200)
gh-102823: Document return type of floor division on floats (GH-102824)
(cherry picked from commit b72251de930c8ec6893f1b3f6fdf1640cc17dfed)

Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Doc/library/stdtypes.rst
Misc/NEWS.d/next/Documentation/2023-03-19-09-39-31.gh-issue-102823.OzsOz0.rst [new file with mode: 0644]

index 804342386abd7fa2ac32588e429d046fb7fa10bf..50f566039111828d2ae0543b33776d532c63785b 100644 (file)
@@ -282,7 +282,7 @@ the operations, see :ref:`operator-summary`):
 +---------------------+---------------------------------+---------+--------------------+
 | ``x / y``           | quotient of *x* and *y*         |         |                    |
 +---------------------+---------------------------------+---------+--------------------+
-| ``x // y``          | floored quotient of *x* and     | \(1)    |                    |
+| ``x // y``          | floored quotient of *x* and     | \(1)\(2)|                    |
 |                     | *y*                             |         |                    |
 +---------------------+---------------------------------+---------+--------------------+
 | ``x % y``           | remainder of ``x / y``          | \(2)    |                    |
@@ -319,8 +319,10 @@ the operations, see :ref:`operator-summary`):
 Notes:
 
 (1)
-   Also referred to as integer division.  The resultant value is a whole
-   integer, though the result's type is not necessarily int.  The result is
+   Also referred to as integer division.  For operands of type :class:`int`,
+   the result has type :class:`int`.  For operands of type :class:`float`,
+   the result has type :class:`float`.  In general, the result is a whole
+   integer, though the result's type is not necessarily :class:`int`.  The result is
    always rounded towards minus infinity: ``1//2`` is ``0``, ``(-1)//2`` is
    ``-1``, ``1//(-2)`` is ``-1``, and ``(-1)//(-2)`` is ``0``.
 
diff --git a/Misc/NEWS.d/next/Documentation/2023-03-19-09-39-31.gh-issue-102823.OzsOz0.rst b/Misc/NEWS.d/next/Documentation/2023-03-19-09-39-31.gh-issue-102823.OzsOz0.rst
new file mode 100644 (file)
index 0000000..1e32f3c
--- /dev/null
@@ -0,0 +1,2 @@
+Document the return type of ``x // y`` when ``x`` and ``y`` have type
+:class:`float`.