e,SrSSKJrJr /SQr"SS\S9r"SS\5r\R\5 "S S \5r \ R\ 5 "S S \ 5r "S S\ 5r \ R\ 5 g)z~Abstract Base Classes (ABCs) for numbers, according to PEP 3141. TODO: Fill out more detailed documentation on the operators.)ABCMetaabstractmethod)NumberComplexRealRationalIntegralc \rSrSrSrSrSrSrg)r%zAll numbers inherit from this class. If you just want to check if an argument x is a number, without caring what kind, use isinstance(x, Number). N)__name__ __module__ __qualname____firstlineno____doc__ __slots____hash____static_attributes__r -/opt/imh/python3.13/lib/python3.13/numbers.pyrr%s IHrr) metaclasscB\rSrSrSrSr\S5rSr\ \S55r \ \S55r \S5r \S 5r \S 5r\S 5rS rS r\S5r\S5r\S5r\S5r\S5r\S5r\S5r\S5r\S5rSrg)r9aNComplex defines the operations that work on the builtin complex type. In short, those are: a conversion to complex, .real, .imag, +, -, *, /, **, abs(), .conjugate, ==, and !=. If it is given heterogeneous arguments, and doesn't have special knowledge about them, it should fall back to the builtin complex type as described below. r cg)zrArDrGrJrNrRrUrXr[rr rrrr9smIKK""""""""""""""""""""""""""""""rrc\rSrSrSrSr\S5r\S5r\S5r \S5r \SS j5r S r S r \S 5r\S 5r\S5r\S5r\S5r\S5rSr\S5r\S5rSrSrg)rzTo Complex, Real adds the operations that work on real numbers. In short, those are: a conversion to float, trunc(), divmod, %, <, <=, >, and >=. Real also provides defaults for the derived operations. r c[e)zLAny Real can be converted to a native float object. Called for float(self).r#rs r __float__Real.__float__ "!rc[e)atrunc(self): Truncates self to an Integral. Returns an Integral i such that: * i > 0 iff self > 0; * abs(i) <= abs(self); * for any Integral j satisfying the first two conditions, abs(i) >= abs(j) [i.e. i has "maximal" abs among those]. i.e. "truncate towards 0". r#rs r __trunc__Real.__trunc__s "!rc[e)z$Finds the greatest Integral <= self.r#rs r __floor__Real.__floor__r0rc[e)z!Finds the least Integral >= self.r#rs r__ceil__ Real.__ceil__r0rNc[e)zRounds self to ndigits decimal places, defaulting to 0. If ndigits is omitted or None, returns an Integral, otherwise returns a Real. Rounds half toward even. r#)rndigitss r __round__Real.__round__r'rcX-X-4$)zdivmod(self, other): The pair (self // other, self % other). Sometimes this can be computed faster than the pair of operations. r r,s r __divmod__Real.__divmod__s  t|,,rcX-X-4$)zdivmod(other, self): The pair (other // self, other % self). Sometimes this can be computed faster than the pair of operations. r r,s r __rdivmod__Real.__rdivmod__s  u|,,rc[e)z)self // other: The floor() of self/other.r#r,s r __floordiv__Real.__floordiv__r0rc[e)z)other // self: The floor() of other/self.r#r,s r __rfloordiv__Real.__rfloordiv__r0rc[e)z self % otherr#r,s r__mod__ Real.__mod__r0rc[e)z other % selfr#r,s r__rmod__ Real.__rmod__r0rc[e)zJself < other < on Reals defines a total ordering, except perhaps for NaN.r#r,s r__lt__ Real.__lt__rcrc[e)z self <= otherr#r,s r__le__ Real.__le__ r0rc*[[U55$)z(complex(self) == complex(float(self), 0))complexfloatrs rrReal.__complex__suT{##rcU7$)z&Real numbers are their real component.r rs rr% Real.real u rcg)z)Real numbers have no imaginary component.rr rs rr) Real.imagrcU7$)zConjugate is a no-op for Reals.r rs rrXReal.conjugates u rN)r rrrrrrrarerhrkrorrrurxr{r~rrrrr]r%r)rXrr rrrrs$I""  " """""""--"""""""""" "" $rrcV\rSrSrSrSr\\S55r\\S55r Sr Sr g)ri$z6.numerator and .denominator should be in lowest terms.r c[err#rs r numeratorRational.numerator)r0rc[err#rs r denominatorRational.denominator.r0rcX[UR5[UR5- $)zfloat(self) = self.numerator / self.denominator It's important that this conversion use the integer's "true" division rather than casting one side to float before dividing so that ratios of huge integers convert without overflowing. )intrrrs rraRational.__float__4s#4>>"S)9)9%:::rN) r rrrrrr]rrrrarr rrrr$sE@I """";rrc\rSrSrSrSr\S5rSr\SSj5r \S5r \S 5r \S 5r \S 5r \S 5r\S 5r\S5r\S5r\S5r\S5r\S5rSr\S5r\S5rSrg)r i?zIntegral adds methods that work on integral numbers. In short, these are conversion to int, pow with modulus, and the bit-string operations. r c[e)z int(self)r#rs r__int__Integral.__int__Hr0rc[U5$)z6Called whenever an index is needed, such as in slicing)rrs r __index__Integral.__index__Ms 4yrNc[e)a self ** exponent % modulus, but maybe faster. Accept the modulus argument if you want to support the 3-argument version of pow(). Raise a TypeError if exponent < 0 or any argument isn't Integral. Otherwise, just implement the 2-argument version described in Complex. r#)rrMmoduluss rrNIntegral.__pow__Qs "!rc[e)z self << otherr#r,s r __lshift__Integral.__lshift__\r0rc[e)z other << selfr#r,s r __rlshift__Integral.__rlshift__ar0rc[e)z self >> otherr#r,s r __rshift__Integral.__rshift__fr0rc[e)z other >> selfr#r,s r __rrshift__Integral.__rrshift__kr0rc[e)z self & otherr#r,s r__and__Integral.__and__pr0rc[e)z other & selfr#r,s r__rand__Integral.__rand__ur0rc[e)z self ^ otherr#r,s r__xor__Integral.__xor__zr0rc[e)z other ^ selfr#r,s r__rxor__Integral.__rxor__r0rc[e)z self | otherr#r,s r__or__Integral.__or__r0rc[e)z other | selfr#r,s r__ror__Integral.__ror__r0rc[e)z~selfr#rs r __invert__Integral.__invert__r0rc*[[U55$)zfloat(self) == float(int(self)))rrrs rraIntegral.__float__sSYrcU7$)z"Integers are their own numerators.r rs rrIntegral.numeratorrrcg)z!Integers have a denominator of 1.r rs rrIntegral.denominatorrrr)r rrrrrrrrrNrrrrrrrrrrrrar]rrrr rrr r ?sB I""""""""""""""""""""""""""  rr N)rabcrr__all__rrregisterrrrrr rr rrrs@:( ? w (n"fn"`s7sj e;t;6axaF #r