From 68f9a49f2c5a9284a259f9e90a7af31de716772c Mon Sep 17 00:00:00 2001 From: Mark Dickinson Date: Sun, 19 Mar 2023 09:39:57 +0000 Subject: [PATCH 1/3] gh-102823: Document return type of floor division on floats --- Doc/library/stdtypes.rst | 6 ++++-- .../2023-03-19-09-39-31.gh-issue-102823.OzsOz0.rst | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Documentation/2023-03-19-09-39-31.gh-issue-102823.OzsOz0.rst diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index bcfc6e5cfce611..c078cd0a831d9d 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -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,7 +319,9 @@ the operations, see :ref:`operator-summary`): Notes: (1) - Also referred to as integer division. The resultant value is a whole + 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 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 index 00000000000000..07f6040061b45b --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2023-03-19-09-39-31.gh-issue-102823.OzsOz0.rst @@ -0,0 +1,2 @@ +Document the return type of `x // y` when `x` and `y` have type +:class:`float`. From 4507d3885f8ca5816a5e9294951090a5752e9397 Mon Sep 17 00:00:00 2001 From: Mark Dickinson Date: Sun, 19 Mar 2023 10:06:38 +0000 Subject: [PATCH 2/3] Fix reST markup in blurb --- .../2023-03-19-09-39-31.gh-issue-102823.OzsOz0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 07f6040061b45b..1e32f3c89231c8 100644 --- 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 @@ -1,2 +1,2 @@ -Document the return type of `x // y` when `x` and `y` have type +Document the return type of ``x // y`` when ``x`` and ``y`` have type :class:`float`. From c55f2f8e700e586d25756001b730ee149cd761c3 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Thu, 7 Sep 2023 17:08:50 +0300 Subject: [PATCH 3/3] Consistently link int --- Doc/library/stdtypes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 45cde016aa5ed5..652ed147af8422 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -322,7 +322,7 @@ Notes: 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 int. The result is + 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``.