Skip to content

Commit

Permalink
pythongh-102823: Document return type of floor division on floats (py…
Browse files Browse the repository at this point in the history
…thon#102824)

Co-authored-by: Hugo van Kemenade <[email protected]>
  • Loading branch information
mdickinson and hugovk authored Sep 7, 2023
1 parent b2729e9 commit b72251d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Doc/library/stdtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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) | |
Expand Down Expand Up @@ -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``.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Document the return type of ``x // y`` when ``x`` and ``y`` have type
:class:`float`.

0 comments on commit b72251d

Please sign in to comment.