Skip to content

Commit b72251d

Browse files
mdickinsonhugovk
andauthored
gh-102823: Document return type of floor division on floats (#102824)
Co-authored-by: Hugo van Kemenade <[email protected]>
1 parent b2729e9 commit b72251d

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Doc/library/stdtypes.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ the operations, see :ref:`operator-summary`):
282282
+---------------------+---------------------------------+---------+--------------------+
283283
| ``x / y`` | quotient of *x* and *y* | | |
284284
+---------------------+---------------------------------+---------+--------------------+
285-
| ``x // y`` | floored quotient of *x* and | \(1) | |
285+
| ``x // y`` | floored quotient of *x* and | \(1)\(2)| |
286286
| | *y* | | |
287287
+---------------------+---------------------------------+---------+--------------------+
288288
| ``x % y`` | remainder of ``x / y`` | \(2) | |
@@ -319,8 +319,10 @@ the operations, see :ref:`operator-summary`):
319319
Notes:
320320

321321
(1)
322-
Also referred to as integer division. The resultant value is a whole
323-
integer, though the result's type is not necessarily int. The result is
322+
Also referred to as integer division. For operands of type :class:`int`,
323+
the result has type :class:`int`. For operands of type :class:`float`,
324+
the result has type :class:`float`. In general, the result is a whole
325+
integer, though the result's type is not necessarily :class:`int`. The result is
324326
always rounded towards minus infinity: ``1//2`` is ``0``, ``(-1)//2`` is
325327
``-1``, ``1//(-2)`` is ``-1``, and ``(-1)//(-2)`` is ``0``.
326328

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Document the return type of ``x // y`` when ``x`` and ``y`` have type
2+
:class:`float`.

0 commit comments

Comments
 (0)