bpo-26680: Incorporate is_integer in all built-in and standard librar… · python/cpython@58a7da9 (original) (raw)

`@@ -49,19 +49,30 @@ The numeric tower

`

49

49

` numbers.

`

50

50

``

51

51

`` In short, those are: a conversion to :class:float, :func:math.trunc,

``

52

``


:func:`round`, :func:`math.floor`, :func:`math.ceil`, :func:`divmod`, ``//``,

53

``


 ``%``, ``<``, ``<=``, ``>``, and ``>=``.

``

52

`` +

:func:round, :func:math.floor, :func:math.ceil, :func:divmod,

``

``

53


:func:`~Real.is_integer`, ``//``, ``%``, ``<``, ``<=``, ``>``, and ``>=``.

54

54

``

55

55

`` Real also provides defaults for :func:complex, :attr:~Complex.real,

``

56

56

`` :attr:~Complex.imag, and :meth:~Complex.conjugate.

``

57

57

``

``

58

`+

.. method:: is_integer()

`

``

59

+

``

60

`` +

Returns :const:True if this number has a finite and integral value,

``

``

61

`` +

otherwise :const:False. This is a default implementation which

``

``

62

`` +

relies on successful conversion to :class:int. It may be overridden

``

``

63

`` +

in subclasses (such as it is in :class:float) for better performance,

``

``

64

`+

or to handle special values such as NaN which are not

`

``

65

`` +

convertible to :class:int.

``

``

66

+

``

67

`+

.. versionadded:: 3.10

`

``

68

+

58

69

``

59

70

`.. class:: Rational

`

60

71

``

61

72

`` Subtypes :class:Real and adds

``

62

73

`` :attr:~Rational.numerator and :attr:~Rational.denominator properties, which

``

63

``

`-

should be in lowest terms. With these, it provides a default for

`

64

``

`` -

:func:float.

``

``

74

`+

should be in lowest terms. With these, it provides defaults for

`

``

75

`` +

:func:float and :func:~Real.is_integer.

``

65

76

``

66

77

` .. attribute:: numerator

`

67

78

``

`@@ -75,9 +86,10 @@ The numeric tower

`

75

86

`.. class:: Integral

`

76

87

``

77

88

`` Subtypes :class:Rational and adds a conversion to :class:int. Provides

``

78

``

`` -

defaults for :func:float, :attr:~Rational.numerator, and

``

79

``


:attr:`~Rational.denominator`. Adds abstract methods for ``**`` and

80

``


 bit-string operations: ``<<``, ``>>``, ``&``, ``^``, ``|``, ``~``.

``

89

`` +

defaults for :func:float, :attr:~Rational.numerator,

``

``

90

`` +

:attr:~Rational.denominator, and :func:~Real.is_integer. Adds abstract

``

``

91


 methods for ``**`` and bit-string operations: ``<<``, ``>>``, ``&``, ``^``,

``

92


 ``|``, ``~``.

81

93

``

82

94

``

83

95

`Notes for type implementors

`