Skip to content

Commit 129fe04

Browse files
committed
Issue python#26512: Clarify Integral; tidy up table of rounding functions
Based on patch by Julien.
1 parent ad1fd34 commit 129fe04

2 files changed

Lines changed: 20 additions & 17 deletions

File tree

Doc/library/stdtypes.rst

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -361,19 +361,22 @@ Notes:
361361
All :class:`numbers.Real` types (:class:`int` and :class:`float`) also include
362362
the following operations:
363363

364-
+--------------------+------------------------------------+--------+
365-
| Operation | Result | Notes |
366-
+====================+====================================+========+
367-
| ``math.trunc(x)`` | *x* truncated to Integral | |
368-
+--------------------+------------------------------------+--------+
369-
| ``round(x[, n])`` | *x* rounded to n digits, | |
370-
| | rounding half to even. If n is | |
371-
| | omitted, it defaults to 0. | |
372-
+--------------------+------------------------------------+--------+
373-
| ``math.floor(x)`` | the greatest integral float <= *x* | |
374-
+--------------------+------------------------------------+--------+
375-
| ``math.ceil(x)`` | the least integral float >= *x* | |
376-
+--------------------+------------------------------------+--------+
364+
+--------------------+---------------------------------------------+
365+
| Operation | Result |
366+
+====================+=============================================+
367+
| :func:`math.trunc(\| *x* truncated to :class:`~numbers.Integral` |
368+
| x) <math.trunc>` | |
369+
+--------------------+---------------------------------------------+
370+
| :func:`round(x[, | *x* rounded to *n* digits, |
371+
| n]) <round>` | rounding half to even. If *n* is |
372+
| | omitted, it defaults to 0. |
373+
+--------------------+---------------------------------------------+
374+
| :func:`math.floor(\| the greatest :class:`~numbers.Integral` |
375+
| x) <math.floor>` | <= *x* |
376+
+--------------------+---------------------------------------------+
377+
| :func:`math.ceil(x)| the least :class:`~numbers.Integral` >= *x* |
378+
| <math.ceil>` | |
379+
+--------------------+---------------------------------------------+
377380

378381
For additional numeric operations see the :mod:`math` and :mod:`cmath`
379382
modules.

Modules/mathmodule.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -957,8 +957,8 @@ static PyObject * math_ceil(PyObject *self, PyObject *number) {
957957
}
958958

959959
PyDoc_STRVAR(math_ceil_doc,
960-
"ceil(x)\n\nReturn the ceiling of x as an int.\n"
961-
"This is the smallest integral value >= x.");
960+
"ceil(x)\n\nReturn the ceiling of x as an Integral.\n"
961+
"This is the smallest integer >= x.");
962962

963963
FUNC2(copysign, copysign,
964964
"copysign(x, y)\n\nReturn a float with the magnitude (absolute value) "
@@ -997,8 +997,8 @@ static PyObject * math_floor(PyObject *self, PyObject *number) {
997997
}
998998

999999
PyDoc_STRVAR(math_floor_doc,
1000-
"floor(x)\n\nReturn the floor of x as an int.\n"
1001-
"This is the largest integral value <= x.");
1000+
"floor(x)\n\nReturn the floor of x as an Integral.\n"
1001+
"This is the largest integer <= x.");
10021002

10031003
FUNC1A(gamma, m_tgamma,
10041004
"gamma(x)\n\nGamma function at x.")

0 commit comments

Comments
 (0)