Continue rolling back pep-3141 changes that changed behavior from 2.5. This
round included:
* Revert round to its 2.6 behavior (half away from 0).
* Because round, floor, and ceil always return float again, it's no
longer necessary to have them delegate to __xxx___, so I've ripped
that out of their implementations and the Real ABC. This also helps
in implementing types that work in both 2.6 and 3.0: you return int
from the __xxx__ methods, and let it get enabled by the version
upgrade.
* Make pow(-1, .5) raise a ValueError again.
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
index 3236ccd..0133e5c 100644
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -986,13 +986,10 @@
.. function:: round(x[, n])
Return the floating point value *x* rounded to *n* digits after the decimal
- point. If *n* is omitted, it defaults to zero. Values are rounded to the
- closest multiple of 10 to the power minus *n*; if two multiples are equally
- close, rounding is done toward the even choice (so, for example, both
- ``round(0.5)`` and ``round(-0.5)`` are ``0``, and ``round(1.5)`` is
- ``2``). Delegates to ``x.__round__(n)``.
-
- .. versionchanged:: 2.6
+ point. If *n* is omitted, it defaults to zero. The result is a floating point
+ number. Values are rounded to the closest multiple of 10 to the power minus
+ *n*; if two multiples are equally close, rounding is done away from 0 (so. for
+ example, ``round(0.5)`` is ``1.0`` and ``round(-0.5)`` is ``-1.0``).
.. function:: set([iterable])
diff --git a/Doc/library/math.rst b/Doc/library/math.rst
index 8c9f0f8..6c78104 100644
--- a/Doc/library/math.rst
+++ b/Doc/library/math.rst
@@ -26,9 +26,8 @@
.. function:: ceil(x)
- Return the ceiling of *x* as a float, the smallest integer value greater than
- or equal to *x*. If *x* is not a float, delegates to ``x.__ceil__()``, which
- should return an :class:`Integral` value.
+ Return the ceiling of *x* as a float, the smallest integer value greater than or
+ equal to *x*.
.. function:: copysign(x, y)
@@ -46,9 +45,8 @@
.. function:: floor(x)
- Return the floor of *x* as a float, the largest integer value less than or
- equal to *x*. If *x* is not a float, delegates to ``x.__floor__()``, which
- should return an :class:`Integral` value.
+ Return the floor of *x* as a float, the largest integer value less than or equal
+ to *x*.
.. function:: fmod(x, y)
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index 7352a1d..7a0e24d 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -341,11 +341,11 @@
pair: C; language
Conversion from floating point to (long or plain) integer may round or
- truncate as in C.
+ truncate as in C; see functions :func:`math.floor` and :func:`math.ceil` for
+ well-defined conversions.
.. deprecated:: 2.6
- Instead, convert floats to long explicitly with :func:`trunc`,
- :func:`math.floor`, or :func:`math.ceil`.
+ Instead, convert floats to long explicitly with :func:`trunc`.
(3)
See :ref:`built-in-funcs` for a full description.
@@ -369,19 +369,19 @@
All :class:`numbers.Real` types (:class:`int`, :class:`long`, and
:class:`float`) also include the following operations:
-+--------------------+--------------------------------+--------+
-| Operation | Result | Notes |
-+====================+================================+========+
-| ``trunc(x)`` | *x* truncated to Integral | |
-+--------------------+--------------------------------+--------+
-| ``round(x[, n])`` | *x* rounded to n digits, | |
-| | rounding half to even. If n is | |
-| | omitted, it defaults to 0. | |
-+--------------------+--------------------------------+--------+
-| ``math.floor(x)`` | the greatest Integral <= *x* | |
-+--------------------+--------------------------------+--------+
-| ``math.ceil(x)`` | the least Integral >= *x* | |
-+--------------------+--------------------------------+--------+
++--------------------+------------------------------------+--------+
+| Operation | Result | Notes |
++====================+====================================+========+
+| ``trunc(x)`` | *x* truncated to Integral | |
++--------------------+------------------------------------+--------+
+| ``round(x[, n])`` | *x* rounded to n digits, | |
+| | rounding half to even. If n is | |
+| | omitted, it defaults to 0. | |
++--------------------+------------------------------------+--------+
+| ``math.floor(x)`` | the greatest integral float <= *x* | |
++--------------------+------------------------------------+--------+
+| ``math.ceil(x)`` | the least integral float >= *x* | |
++--------------------+------------------------------------+--------+
.. XXXJH exceptions: overflow (when? what operations?) zerodivision