
    F\h,                         S r SSKJrJr  / SQr " S S\S9r " S S\5      r\R                  \5         " S	 S
\5      r	\	R                  \
5         " S S\	5      r " S S\5      r\R                  \5        g)z~Abstract Base Classes (ABCs) for numbers, according to PEP 3141.

TODO: Fill out more detailed documentation on the operators.    )ABCMetaabstractmethod)NumberComplexRealRationalIntegralc                        \ rS rSrSrSrSrSrg)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       /usr/lib/python3.13/numbers.pyr   r   %   s    
 I Hr   r   )	metaclassc                   B   \ rS rSrSrSr\S 5       rS r\	\S 5       5       r
\	\S 5       5       r\S 5       r\S	 5       r\S
 5       r\S 5       rS rS r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       rSrg)r   9   aN  Complex 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   c                     g)z<Return a builtin complex instance. Called for complex(self).Nr   selfs    r   __complex__Complex.__complex__F   s    r   c                     U S:g  $ )z)True if self != 0. Called for bool(self).r   r   r   s    r   __bool__Complex.__bool__J   s    qyr   c                     [         e)zHRetrieve the real component of this number.

This should subclass Real.
NotImplementedErrorr   s    r   realComplex.realN   
     "!r   c                     [         e)zMRetrieve the imaginary component of this number.

This should subclass Real.
r#   r   s    r   imagComplex.imagW   r'   r   c                     [         e)zself + otherr#   r   others     r   __add__Complex.__add__`   
     "!r   c                     [         e)zother + selfr#   r,   s     r   __radd__Complex.__radd__e   r0   r   c                     [         e)z-selfr#   r   s    r   __neg__Complex.__neg__j   r0   r   c                     [         e)z+selfr#   r   s    r   __pos__Complex.__pos__o   r0   r   c                     X* -   $ )zself - otherr   r,   s     r   __sub__Complex.__sub__t   s    f}r   c                     U * U-   $ )zother - selfr   r,   s     r   __rsub__Complex.__rsub__x   s    uu}r   c                     [         e)zself * otherr#   r,   s     r   __mul__Complex.__mul__|   r0   r   c                     [         e)zother * selfr#   r,   s     r   __rmul__Complex.__rmul__   r0   r   c                     [         e)z5self / other: Should promote to float when necessary.r#   r,   s     r   __truediv__Complex.__truediv__   r0   r   c                     [         e)zother / selfr#   r,   s     r   __rtruediv__Complex.__rtruediv__   r0   r   c                     [         e)zDself ** exponent; should promote to float or complex when necessary.r#   )r   exponents     r   __pow__Complex.__pow__   r0   r   c                     [         e)zbase ** selfr#   )r   bases     r   __rpow__Complex.__rpow__   r0   r   c                     [         e)z7Returns the Real distance from 0. Called for abs(self).r#   r   s    r   __abs__Complex.__abs__   r0   r   c                     [         e)z$(x+y*i).conjugate() returns (x-y*i).r#   r   s    r   	conjugateComplex.conjugate   r0   r   c                     [         e)zself == otherr#   r,   s     r   __eq__Complex.__eq__   r0   r   N)r   r   r   r   r   r   r   r   r    propertyr%   r)   r.   r2   r5   r8   r;   r>   rA   rD   rG   rJ   rN   rR   rU   rX   r[   r   r   r   r   r   r   9   sm    IK K "  " "  " " " " " " " " " " " " " " " " " " " " " " " " " " "r   r   c                      \ rS rSrSrSr\S 5       r\S 5       r\S 5       r	\S 5       r
\SS	 j5       rS
 rS r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       rS r\S 5       r\S 5       rS rSrg)r      zTo 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#   r   s    r   	__float__Real.__float__   
    
 "!r   c                     [         e)a  trunc(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#   r   s    r   	__trunc__Real.__trunc__   s
     "!r   c                     [         e)z$Finds the greatest Integral <= self.r#   r   s    r   	__floor__Real.__floor__   r0   r   c                     [         e)z!Finds the least Integral >= self.r#   r   s    r   __ceil__Real.__ceil__   r0   r   Nc                     [         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#   )r   ndigitss     r   	__round__Real.__round__   r'   r   c                     X-  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|,,r   c                     X-  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|,,r   c                     [         e)z)self // other: The floor() of self/other.r#   r,   s     r   __floordiv__Real.__floordiv__   r0   r   c                     [         e)z)other // self: The floor() of other/self.r#   r,   s     r   __rfloordiv__Real.__rfloordiv__   r0   r   c                     [         e)zself % otherr#   r,   s     r   __mod__Real.__mod__   r0   r   c                     [         e)zother % selfr#   r,   s     r   __rmod__Real.__rmod__   r0   r   c                     [         e)zJself < other

< on Reals defines a total ordering, except perhaps for NaN.r#   r,   s     r   __lt__Real.__lt__  rc   r   c                     [         e)zself <= otherr#   r,   s     r   __le__Real.__le__	  r0   r   c                 *    [        [        U 5      5      $ )z(complex(self) == complex(float(self), 0))complexfloatr   s    r   r   Real.__complex__  s    uT{##r   c                     U 7$ )z&Real numbers are their real component.r   r   s    r   r%   	Real.real       ur   c                     g)z)Real numbers have no imaginary component.r   r   r   s    r   r)   	Real.imag       r   c                     U 7$ )zConjugate is a no-op for Reals.r   r   s    r   rX   Real.conjugate  s	    ur   N)r   r   r   r   r   r   r   ra   re   rh   rk   ro   rr   ru   rx   r{   r~   r   r   r   r   r]   r%   r)   rX   r   r   r   r   r   r      s$    I" " 
" 
" " " " " " "-- " " " " " " " " " " " "
$    r   r   c                   V    \ rS rSrSrSr\\S 5       5       r\\S 5       5       r	S r
Srg)r   i$  z6.numerator and .denominator should be in lowest terms.r   c                     [         er   r#   r   s    r   	numeratorRational.numerator)  r0   r   c                     [         er   r#   r   s    r   denominatorRational.denominator.  r0   r   c                 X    [        U R                  5      [        U R                  5      -  $ )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.

)intr   r   r   s    r   ra   Rational.__float__4  s#     4>>"S)9)9%:::r   N)r   r   r   r   r   r   r]   r   r   r   ra   r   r   r   r   r   r   $  sE    @I"  " "  ";r   r   c                      \ rS rSrSrSr\S 5       rS r\SS j5       r	\S 5       r
\S	 5       r\S
 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       rS r\S 5       r\S 5       rSrg)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#   r   s    r   __int__Integral.__int__H  r0   r   c                     [        U 5      $ )z6Called whenever an index is needed, such as in slicing)r   r   s    r   	__index__Integral.__index__M  s    4yr   Nc                     [         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#   )r   rM   moduluss      r   rN   Integral.__pow__Q  s
     "!r   c                     [         e)zself << otherr#   r,   s     r   
__lshift__Integral.__lshift__\  r0   r   c                     [         e)zother << selfr#   r,   s     r   __rlshift__Integral.__rlshift__a  r0   r   c                     [         e)zself >> otherr#   r,   s     r   
__rshift__Integral.__rshift__f  r0   r   c                     [         e)zother >> selfr#   r,   s     r   __rrshift__Integral.__rrshift__k  r0   r   c                     [         e)zself & otherr#   r,   s     r   __and__Integral.__and__p  r0   r   c                     [         e)zother & selfr#   r,   s     r   __rand__Integral.__rand__u  r0   r   c                     [         e)zself ^ otherr#   r,   s     r   __xor__Integral.__xor__z  r0   r   c                     [         e)zother ^ selfr#   r,   s     r   __rxor__Integral.__rxor__  r0   r   c                     [         e)zself | otherr#   r,   s     r   __or__Integral.__or__  r0   r   c                     [         e)zother | selfr#   r,   s     r   __ror__Integral.__ror__  r0   r   c                     [         e)z~selfr#   r   s    r   
__invert__Integral.__invert__  r0   r   c                 *    [        [        U 5      5      $ )zfloat(self) == float(int(self)))r   r   r   s    r   ra   Integral.__float__  s    SYr   c                     U 7$ )z"Integers are their own numerators.r   r   s    r   r   Integral.numerator  r   r   c                     g)z!Integers have a denominator of 1.   r   r   s    r   r   Integral.denominator  r   r   r   )r   r   r   r   r   r   r   r   r   rN   r   r   r   r   r   r   r   r   r   r   r   ra   r]   r   r   r   r   r   r   r	   r	   ?  sB    I" " " " " " " " " " " " " " " " " " " " " " " " " "
     r   r	   N)r   abcr   r   __all__r   r   registerr   r   r   r   r	   r   r   r   r   <module>r      s   @: (
?	w 	(n"f n"`    s7 sj e ;t ;6ax aF 	  # r   