Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 809ddaa

Browse files
committed
#3191: fix round() docs and docstring.
1 parent 13b6d0d commit 809ddaa

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

Doc/library/functions.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -964,11 +964,15 @@ are always available. They are listed here in alphabetical order.
964964
.. function:: round(x[, n])
965965

966966
Return the floating point value *x* rounded to *n* digits after the decimal
967-
point. If *n* is omitted, it defaults to zero. Values are rounded to the
967+
point. If *n* is omitted, it defaults to zero. Delegates to
968+
``x.__round__(n)``.
969+
970+
For the built-in types supporting :func:`round`, values are rounded to the
968971
closest multiple of 10 to the power minus *n*; if two multiples are equally
969972
close, rounding is done toward the even choice (so, for example, both
970-
``round(0.5)`` and ``round(-0.5)`` are ``0``, and ``round(1.5)`` is
971-
``2``). Delegates to ``x.__round__(n)``.
973+
``round(0.5)`` and ``round(-0.5)`` are ``0``, and ``round(1.5)`` is ``2``).
974+
The return value is an integer if called with one argument, otherwise of the
975+
same type as *x*.
972976

973977

974978
.. function:: set([iterable])

Python/bltinmodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,8 +1726,8 @@ PyDoc_STRVAR(round_doc,
17261726
"round(number[, ndigits]) -> floating point number\n\
17271727
\n\
17281728
Round a number to a given precision in decimal digits (default 0 digits).\n\
1729-
This returns an int when called with one argument, otherwise a float.\n\
1730-
Precision may be negative.");
1729+
This returns an int when called with one argument, otherwise a the\n\
1730+
same type as the number. ndigits may be negative.");
17311731

17321732

17331733
static PyObject *

0 commit comments

Comments
 (0)