diff options
author | Raymond Hettinger <rhettinger@users.noreply.github.com> | 2020-10-07 23:43:44 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-07 23:43:44 (GMT) |
commit | 4e0ce820586e93cfcefb16c2a3df8eaefc54cbca (patch) | |
tree | 62e95d644abcbc04dd6baedc9b3f44f42d4d974f /Doc/library | |
parent | 4f3c25043d651a13c41cffcee703f7d5cb677cc7 (diff) | |
download | cpython-4e0ce820586e93cfcefb16c2a3df8eaefc54cbca.zip cpython-4e0ce820586e93cfcefb16c2a3df8eaefc54cbca.tar.gz cpython-4e0ce820586e93cfcefb16c2a3df8eaefc54cbca.tar.bz2 |
Revert "bpo-26680: Incorporate is_integer in all built-in and standard library numeric types (GH-6121)" (GH-22584)
This reverts commit 58a7da9e125422323f79c4ee95ac5549989d8162.
Diffstat (limited to 'Doc/library')
-rw-r--r-- | Doc/library/decimal.rst | 14 | ||||
-rw-r--r-- | Doc/library/numbers.rst | 26 | ||||
-rw-r--r-- | Doc/library/stdtypes.rst | 14 |
3 files changed, 17 insertions, 37 deletions
diff --git a/Doc/library/decimal.rst b/Doc/library/decimal.rst index 7a64973..e194649 100644 --- a/Doc/library/decimal.rst +++ b/Doc/library/decimal.rst @@ -621,13 +621,6 @@ Decimal objects Return :const:`True` if the argument is either positive or negative infinity and :const:`False` otherwise. - .. method:: is_integer() - - Return :const:`True` if the argument is a finite integral value and - :const:`False` otherwise. - - .. versionadded:: 3.10 - .. method:: is_nan() Return :const:`True` if the argument is a (quiet or signaling) NaN and @@ -1222,13 +1215,6 @@ In addition to the three supplied contexts, new contexts can be created with the Returns ``True`` if *x* is infinite; otherwise returns ``False``. - .. method:: is_integer(x) - - Returns ``True`` if *x* is finite and integral; otherwise - returns ``False``. - - .. versionadded:: 3.10 - .. method:: is_nan(x) Returns ``True`` if *x* is a qNaN or sNaN; otherwise returns ``False``. diff --git a/Doc/library/numbers.rst b/Doc/library/numbers.rst index 5d49f5e..1b59495 100644 --- a/Doc/library/numbers.rst +++ b/Doc/library/numbers.rst @@ -49,30 +49,19 @@ The numeric tower numbers. In short, those are: a conversion to :class:`float`, :func:`math.trunc`, - :func:`round`, :func:`math.floor`, :func:`math.ceil`, :func:`divmod`, - :func:`~Real.is_integer`, ``//``, ``%``, ``<``, ``<=``, ``>``, and ``>=``. + :func:`round`, :func:`math.floor`, :func:`math.ceil`, :func:`divmod`, ``//``, + ``%``, ``<``, ``<=``, ``>``, and ``>=``. Real also provides defaults for :func:`complex`, :attr:`~Complex.real`, :attr:`~Complex.imag`, and :meth:`~Complex.conjugate`. - .. method:: is_integer() - - Returns :const:`True` if this number has a finite and integral value, - otherwise :const:`False`. This is a default implementation which - relies on successful conversion to :class:`int`. It may be overridden - in subclasses (such as it is in :class:`float`) for better performance, - or to handle special values such as NaN which are not - convertible to :class:`int`. - - .. versionadded:: 3.10 - .. class:: Rational Subtypes :class:`Real` and adds :attr:`~Rational.numerator` and :attr:`~Rational.denominator` properties, which - should be in lowest terms. With these, it provides defaults for - :func:`float` and :func:`~Real.is_integer`. + should be in lowest terms. With these, it provides a default for + :func:`float`. .. attribute:: numerator @@ -86,10 +75,9 @@ The numeric tower .. class:: Integral Subtypes :class:`Rational` and adds a conversion to :class:`int`. Provides - defaults for :func:`float`, :attr:`~Rational.numerator`, - :attr:`~Rational.denominator`, and :func:`~Real.is_integer`. Adds abstract - methods for ``**`` and bit-string operations: ``<<``, ``>>``, ``&``, ``^``, - ``|``, ``~``. + defaults for :func:`float`, :attr:`~Rational.numerator`, and + :attr:`~Rational.denominator`. Adds abstract methods for ``**`` and + bit-string operations: ``<<``, ``>>``, ``&``, ``^``, ``|``, ``~``. Notes for type implementors diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 04dfea2..5c6acc6 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -310,10 +310,6 @@ the operations, see :ref:`operator-summary`): +---------------------+---------------------------------+---------+--------------------+ | ``x ** y`` | *x* to the power *y* | \(5) | | +---------------------+---------------------------------+---------+--------------------+ -| ``x.is_integer()`` | ``True`` if *x* has a finite | | :func:`~numbers\ | -| | and integral value, otherwise | | .Real.is_integer` | -| | ``False``. | | | -+---------------------+---------------------------------+---------+--------------------+ .. index:: triple: operations on; numeric; types @@ -587,6 +583,16 @@ class`. float also has the following additional methods. :exc:`OverflowError` on infinities and a :exc:`ValueError` on NaNs. +.. method:: float.is_integer() + + Return ``True`` if the float instance is finite with integral + value, and ``False`` otherwise:: + + >>> (-2.0).is_integer() + True + >>> (3.2).is_integer() + False + Two methods support conversion to and from hexadecimal strings. Since Python's floats are stored internally as binary numbers, converting a float to or from a |