{
    "mode": "pydoc",
    "parameter": "numbers",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/pydoc/numbers/json",
    "generated": "2026-06-02T15:07:00Z",
    "sections": {
        "NAME": {
            "content": "numbers - Abstract Base Classes (ABCs) for numbers, according to PEP 3141.\n",
            "subsections": []
        },
        "MODULE REFERENCE": {
            "content": "https://docs.python.org/3.10/library/numbers.html\n\nThe following documentation is automatically generated from the Python\nsource files.  It may be incomplete, incorrect or include features that\nare considered implementation detail and may vary between Python\nimplementations.  When in doubt, consult the module reference at the\nlocation listed above.\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "TODO: Fill out more detailed documentation on the operators.\n",
            "subsections": []
        },
        "CLASSES": {
            "content": "builtins.object\nNumber\nComplex\nReal\nRational\nIntegral\n",
            "subsections": [
                {
                    "name": "class Complex",
                    "content": "|  Complex defines the operations that work on the builtin complex type.\n|\n|  In short, those are: a conversion to complex, .real, .imag, +, -,\n|  *, /, , abs(), .conjugate, ==, and !=.\n|\n|  If it is given heterogeneous arguments, and doesn't have special\n|  knowledge about them, it should fall back to the builtin complex\n|  type as described below.\n|\n|  Method resolution order:\n|      Complex\n|      Number\n|      builtins.object\n|\n|  Methods defined here:\n|\n|  abs(self)\n|      Returns the Real distance from 0. Called for abs(self).\n|\n|  add(self, other)\n|      self + other\n|\n|  bool(self)\n|      True if self != 0. Called for bool(self).\n|\n|  complex(self)\n|      Return a builtin complex instance. Called for complex(self).\n|\n|  eq(self, other)\n|      self == other\n|\n|  mul(self, other)\n|      self * other\n|\n|  neg(self)\n|      -self\n|\n|  pos(self)\n|      +self\n|\n|  pow(self, exponent)\n|      selfexponent; should promote to float or complex when necessary.\n|\n|  radd(self, other)\n|      other + self\n|\n|  rmul(self, other)\n|      other * self\n|\n|  rpow(self, base)\n|      base  self\n|\n|  rsub(self, other)\n|      other - self\n|\n|  rtruediv(self, other)\n|      other / self\n|\n|  sub(self, other)\n|      self - other\n|\n|  truediv(self, other)\n|      self / other: Should promote to float when necessary.\n|\n|  conjugate(self)\n|      (x+y*i).conjugate() returns (x-y*i).\n|\n|  ----------------------------------------------------------------------\n|  Readonly properties defined here:\n|\n|  imag\n|      Retrieve the imaginary component of this number.\n|\n|      This should subclass Real.\n|\n|  real\n|      Retrieve the real component of this number.\n|\n|      This should subclass Real.\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes defined here:\n|\n|  abstractmethods = frozenset({'abs', 'add', 'complex', ...\n|\n|  hash = None\n"
                },
                {
                    "name": "class Integral",
                    "content": "|  Integral adds methods that work on integral numbers.\n|\n|  In short, these are conversion to int, pow with modulus, and the\n|  bit-string operations.\n|\n|  Method resolution order:\n|      Integral\n|      Rational\n|      Real\n|      Complex\n|      Number\n|      builtins.object\n|\n|  Methods defined here:\n|\n|  and(self, other)\n|      self & other\n|\n|  float(self)\n|      float(self) == float(int(self))\n|\n|  index(self)\n|      Called whenever an index is needed, such as in slicing\n|\n|  int(self)\n|      int(self)\n|\n|  invert(self)\n|      ~self\n|\n|  lshift(self, other)\n|      self << other\n|\n|  or(self, other)\n|      self | other\n|\n|  pow(self, exponent, modulus=None)\n|      self  exponent % modulus, but maybe faster.\n|\n|      Accept the modulus argument if you want to support the\n|      3-argument version of pow(). Raise a TypeError if exponent < 0\n|      or any argument isn't Integral. Otherwise, just implement the\n|      2-argument version described in Complex.\n|\n|  rand(self, other)\n|      other & self\n|\n|  rlshift(self, other)\n|      other << self\n|\n|  ror(self, other)\n|      other | self\n|\n|  rrshift(self, other)\n|      other >> self\n|\n|  rshift(self, other)\n|      self >> other\n|\n|  rxor(self, other)\n|      other ^ self\n|\n|  xor(self, other)\n|      self ^ other\n|\n|  ----------------------------------------------------------------------\n|  Readonly properties defined here:\n|\n|  denominator\n|      Integers have a denominator of 1.\n|\n|  numerator\n|      Integers are their own numerators.\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes defined here:\n|\n|  abstractmethods = frozenset({'abs', 'add', 'and', 'c...\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from Real:\n|\n|  ceil(self)\n|      Finds the least Integral >= self.\n|\n|  complex(self)\n|      complex(self) == complex(float(self), 0)\n|\n|  divmod(self, other)\n|      divmod(self, other): The pair (self // other, self % other).\n|\n|      Sometimes this can be computed faster than the pair of\n|      operations.\n|\n|  floor(self)\n|      Finds the greatest Integral <= self.\n|\n|  floordiv(self, other)\n|      self // other: The floor() of self/other.\n|\n|  le(self, other)\n|      self <= other\n|\n|  lt(self, other)\n|      self < other\n|\n|      < on Reals defines a total ordering, except perhaps for NaN.\n|\n|  mod(self, other)\n|      self % other\n|\n|  rdivmod(self, other)\n|      divmod(other, self): The pair (self // other, self % other).\n|\n|      Sometimes this can be computed faster than the pair of\n|      operations.\n|\n|  rfloordiv(self, other)\n|      other // self: The floor() of other/self.\n|\n|  rmod(self, other)\n|      other % self\n|\n|  round(self, ndigits=None)\n|      Rounds self to ndigits decimal places, defaulting to 0.\n|\n|      If ndigits is omitted or None, returns an Integral, otherwise\n|      returns a Real. Rounds half toward even.\n|\n|  trunc(self)\n|      trunc(self): Truncates self to an Integral.\n|\n|      Returns an Integral i such that:\n|        * i>0 iff self>0;\n|        * abs(i) <= abs(self);\n|        * for any Integral j satisfying the first two conditions,\n|          abs(i) >= abs(j) [i.e. i has \"maximal\" abs among those].\n|      i.e. \"truncate towards 0\".\n|\n|  conjugate(self)\n|      Conjugate is a no-op for Reals.\n|\n|  ----------------------------------------------------------------------\n|  Readonly properties inherited from Real:\n|\n|  imag\n|      Real numbers have no imaginary component.\n|\n|  real\n|      Real numbers are their real component.\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from Complex:\n|\n|  abs(self)\n|      Returns the Real distance from 0. Called for abs(self).\n|\n|  add(self, other)\n|      self + other\n|\n|  bool(self)\n|      True if self != 0. Called for bool(self).\n|\n|  eq(self, other)\n|      self == other\n|\n|  mul(self, other)\n|      self * other\n|\n|  neg(self)\n|      -self\n|\n|  pos(self)\n|      +self\n|\n|  radd(self, other)\n|      other + self\n|\n|  rmul(self, other)\n|      other * self\n|\n|  rpow(self, base)\n|      base  self\n|\n|  rsub(self, other)\n|      other - self\n|\n|  rtruediv(self, other)\n|      other / self\n|\n|  sub(self, other)\n|      self - other\n|\n|  truediv(self, other)\n|      self / other: Should promote to float when necessary.\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes inherited from Complex:\n|\n|  hash = None\n"
                },
                {
                    "name": "class Number",
                    "content": "|  All numbers inherit from this class.\n|\n|  If you just want to check if an argument x is a number, without\n|  caring what kind, use isinstance(x, Number).\n|\n|  Data and other attributes defined here:\n|\n|  abstractmethods = frozenset()\n|\n|  hash = None\n"
                },
                {
                    "name": "class Rational",
                    "content": "|  .numerator and .denominator should be in lowest terms.\n|\n|  Method resolution order:\n|      Rational\n|      Real\n|      Complex\n|      Number\n|      builtins.object\n|\n|  Methods defined here:\n|\n|  float(self)\n|      float(self) = self.numerator / self.denominator\n|\n|      It's important that this conversion use the integer's \"true\"\n|      division rather than casting one side to float before dividing\n|      so that ratios of huge integers convert without overflowing.\n|\n|  ----------------------------------------------------------------------\n|  Readonly properties defined here:\n|\n|  denominator\n|\n|  numerator\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes defined here:\n|\n|  abstractmethods = frozenset({'abs', 'add', 'ceil', '...\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from Real:\n|\n|  ceil(self)\n|      Finds the least Integral >= self.\n|\n|  complex(self)\n|      complex(self) == complex(float(self), 0)\n|\n|  divmod(self, other)\n|      divmod(self, other): The pair (self // other, self % other).\n|\n|      Sometimes this can be computed faster than the pair of\n|      operations.\n|\n|  floor(self)\n|      Finds the greatest Integral <= self.\n|\n|  floordiv(self, other)\n|      self // other: The floor() of self/other.\n|\n|  le(self, other)\n|      self <= other\n|\n|  lt(self, other)\n|      self < other\n|\n|      < on Reals defines a total ordering, except perhaps for NaN.\n|\n|  mod(self, other)\n|      self % other\n|\n|  rdivmod(self, other)\n|      divmod(other, self): The pair (self // other, self % other).\n|\n|      Sometimes this can be computed faster than the pair of\n|      operations.\n|\n|  rfloordiv(self, other)\n|      other // self: The floor() of other/self.\n|\n|  rmod(self, other)\n|      other % self\n|\n|  round(self, ndigits=None)\n|      Rounds self to ndigits decimal places, defaulting to 0.\n|\n|      If ndigits is omitted or None, returns an Integral, otherwise\n|      returns a Real. Rounds half toward even.\n|\n|  trunc(self)\n|      trunc(self): Truncates self to an Integral.\n|\n|      Returns an Integral i such that:\n|        * i>0 iff self>0;\n|        * abs(i) <= abs(self);\n|        * for any Integral j satisfying the first two conditions,\n|          abs(i) >= abs(j) [i.e. i has \"maximal\" abs among those].\n|      i.e. \"truncate towards 0\".\n|\n|  conjugate(self)\n|      Conjugate is a no-op for Reals.\n|\n|  ----------------------------------------------------------------------\n|  Readonly properties inherited from Real:\n|\n|  imag\n|      Real numbers have no imaginary component.\n|\n|  real\n|      Real numbers are their real component.\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from Complex:\n|\n|  abs(self)\n|      Returns the Real distance from 0. Called for abs(self).\n|\n|  add(self, other)\n|      self + other\n|\n|  bool(self)\n|      True if self != 0. Called for bool(self).\n|\n|  eq(self, other)\n|      self == other\n|\n|  mul(self, other)\n|      self * other\n|\n|  neg(self)\n|      -self\n|\n|  pos(self)\n|      +self\n|\n|  pow(self, exponent)\n|      selfexponent; should promote to float or complex when necessary.\n|\n|  radd(self, other)\n|      other + self\n|\n|  rmul(self, other)\n|      other * self\n|\n|  rpow(self, base)\n|      base  self\n|\n|  rsub(self, other)\n|      other - self\n|\n|  rtruediv(self, other)\n|      other / self\n|\n|  sub(self, other)\n|      self - other\n|\n|  truediv(self, other)\n|      self / other: Should promote to float when necessary.\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes inherited from Complex:\n|\n|  hash = None\n"
                },
                {
                    "name": "class Real",
                    "content": "|  To Complex, Real adds the operations that work on real numbers.\n|\n|  In short, those are: a conversion to float, trunc(), divmod,\n|  %, <, <=, >, and >=.\n|\n|  Real also provides defaults for the derived operations.\n|\n|  Method resolution order:\n|      Real\n|      Complex\n|      Number\n|      builtins.object\n|\n|  Methods defined here:\n|\n|  ceil(self)\n|      Finds the least Integral >= self.\n|\n|  complex(self)\n|      complex(self) == complex(float(self), 0)\n|\n|  divmod(self, other)\n|      divmod(self, other): The pair (self // other, self % other).\n|\n|      Sometimes this can be computed faster than the pair of\n|      operations.\n|\n|  float(self)\n|      Any Real can be converted to a native float object.\n|\n|      Called for float(self).\n|\n|  floor(self)\n|      Finds the greatest Integral <= self.\n|\n|  floordiv(self, other)\n|      self // other: The floor() of self/other.\n|\n|  le(self, other)\n|      self <= other\n|\n|  lt(self, other)\n|      self < other\n|\n|      < on Reals defines a total ordering, except perhaps for NaN.\n|\n|  mod(self, other)\n|      self % other\n|\n|  rdivmod(self, other)\n|      divmod(other, self): The pair (self // other, self % other).\n|\n|      Sometimes this can be computed faster than the pair of\n|      operations.\n|\n|  rfloordiv(self, other)\n|      other // self: The floor() of other/self.\n|\n|  rmod(self, other)\n|      other % self\n|\n|  round(self, ndigits=None)\n|      Rounds self to ndigits decimal places, defaulting to 0.\n|\n|      If ndigits is omitted or None, returns an Integral, otherwise\n|      returns a Real. Rounds half toward even.\n|\n|  trunc(self)\n|      trunc(self): Truncates self to an Integral.\n|\n|      Returns an Integral i such that:\n|        * i>0 iff self>0;\n|        * abs(i) <= abs(self);\n|        * for any Integral j satisfying the first two conditions,\n|          abs(i) >= abs(j) [i.e. i has \"maximal\" abs among those].\n|      i.e. \"truncate towards 0\".\n|\n|  conjugate(self)\n|      Conjugate is a no-op for Reals.\n|\n|  ----------------------------------------------------------------------\n|  Readonly properties defined here:\n|\n|  imag\n|      Real numbers have no imaginary component.\n|\n|  real\n|      Real numbers are their real component.\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes defined here:\n|\n|  abstractmethods = frozenset({'abs', 'add', 'ceil', '...\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from Complex:\n|\n|  abs(self)\n|      Returns the Real distance from 0. Called for abs(self).\n|\n|  add(self, other)\n|      self + other\n|\n|  bool(self)\n|      True if self != 0. Called for bool(self).\n|\n|  eq(self, other)\n|      self == other\n|\n|  mul(self, other)\n|      self * other\n|\n|  neg(self)\n|      -self\n|\n|  pos(self)\n|      +self\n|\n|  pow(self, exponent)\n|      selfexponent; should promote to float or complex when necessary.\n|\n|  radd(self, other)\n|      other + self\n|\n|  rmul(self, other)\n|      other * self\n|\n|  rpow(self, base)\n|      base  self\n|\n|  rsub(self, other)\n|      other - self\n|\n|  rtruediv(self, other)\n|      other / self\n|\n|  sub(self, other)\n|      self - other\n|\n|  truediv(self, other)\n|      self / other: Should promote to float when necessary.\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes inherited from Complex:\n|\n|  hash = None\n"
                }
            ]
        },
        "DATA": {
            "content": "all = ['Number', 'Complex', 'Real', 'Rational', 'Integral']\n",
            "subsections": []
        },
        "FILE": {
            "content": "/usr/lib/python3.10/numbers.py\n\n",
            "subsections": []
        }
    },
    "summary": "numbers - Abstract Base Classes (ABCs) for numbers, according to PEP 3141.",
    "flags": [],
    "examples": [],
    "see_also": []
}