
    dl(                     .   d Z ddlmZmZ g dZ G d de          Z G d de          Ze                    e            G d	 d
e          Z	e	                    e
            G d de	          Z G d de          Ze                    e           dS )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                       e Zd ZdZdZdZdS )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____doc__	__slots____hash__r         /croot/python-split_1694437901252/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/lib/python3.11/numbers.pyr   r      s&         
 I HHHr   r   )	metaclassc                      e Zd ZdZdZed             Zd Zeed                         Z	eed                         Z
ed             Zed             Zed	             Zed
             Zd Zd Zed             Zed             Zed             Zed             Zed             Zed             Zed             Zed             Zed             ZdS )r   af  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                     dS )z<Return a builtin complex instance. Called for complex(self).Nr   selfs    r   __complex__zComplex.__complex__-   s      r   c                     | dk    S )z)True if self != 0. Called for bool(self).r   r   r   s    r   __bool__zComplex.__bool__1   s    qyr   c                     t           )zXRetrieve the real component of this number.

        This should subclass Real.
        NotImplementedErrorr   s    r   realzComplex.real5   
     "!r   c                     t           )z]Retrieve the imaginary component of this number.

        This should subclass Real.
        r   r   s    r   imagzComplex.imag>   r    r   c                     t           )zself + otherr   r   others     r   __add__zComplex.__add__G   
     "!r   c                     t           )zother + selfr   r$   s     r   __radd__zComplex.__radd__L   r'   r   c                     t           )z-selfr   r   s    r   __neg__zComplex.__neg__Q   r'   r   c                     t           )z+selfr   r   s    r   __pos__zComplex.__pos__V   r'   r   c                     | | z   S )zself - otherr   r$   s     r   __sub__zComplex.__sub__[   s    uf}r   c                     |  |z   S )zother - selfr   r$   s     r   __rsub__zComplex.__rsub___   s    uu}r   c                     t           )zself * otherr   r$   s     r   __mul__zComplex.__mul__c   r'   r   c                     t           )zother * selfr   r$   s     r   __rmul__zComplex.__rmul__h   r'   r   c                     t           )z5self / other: Should promote to float when necessary.r   r$   s     r   __truediv__zComplex.__truediv__m   r'   r   c                     t           )zother / selfr   r$   s     r   __rtruediv__zComplex.__rtruediv__r   r'   r   c                     t           )zBself**exponent; should promote to float or complex when necessary.r   )r   exponents     r   __pow__zComplex.__pow__w   r'   r   c                     t           )zbase ** selfr   )r   bases     r   __rpow__zComplex.__rpow__|   r'   r   c                     t           )z7Returns the Real distance from 0. Called for abs(self).r   r   s    r   __abs__zComplex.__abs__   r'   r   c                     t           )z$(x+y*i).conjugate() returns (x-y*i).r   r   s    r   	conjugatezComplex.conjugate   r'   r   c                     t           )zself == otherr   r$   s     r   __eq__zComplex.__eq__   r'   r   N)r   r   r   r   r   r   r   r   propertyr   r"   r&   r)   r+   r-   r/   r1   r3   r5   r7   r9   r<   r?   rA   rC   rE   r   r   r   r   r       s         IK K ^K   " " ^ X" " " ^ X" " " ^" " " ^" " " ^" " " ^"     " " ^" " " ^" " " ^" " " ^" " " ^" " " ^" " " ^" " " ^" " " ^" " "r   r   c                   N   e Zd ZdZdZed             Zed             Zed             Zed             Z	edd            Z
d	 Zd
 Zed             Zed             Zed             Zed             Zed             Zed             Zd Zed             Zed             Zd ZdS )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                     t           )zTAny Real can be converted to a native float object.

        Called for float(self).r   r   s    r   	__float__zReal.__float__   
    
 "!r   c                     t           )aG  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__zReal.__trunc__   s
     "!r   c                     t           )z$Finds the greatest Integral <= self.r   r   s    r   	__floor__zReal.__floor__   r'   r   c                     t           )z!Finds the least Integral >= self.r   r   s    r   __ceil__zReal.__ceil__   r'   r   Nc                     t           )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__zReal.__round__   r    r   c                     | |z  | |z  fS )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__zReal.__divmod__   s     te|,,r   c                     || z  || z  fS )zdivmod(other, self): The pair (self // other, self % other).

        Sometimes this can be computed faster than the pair of
        operations.
        r   r$   s     r   __rdivmod__zReal.__rdivmod__   s     ut|,,r   c                     t           )z)self // other: The floor() of self/other.r   r$   s     r   __floordiv__zReal.__floordiv__   r'   r   c                     t           )z)other // self: The floor() of other/self.r   r$   s     r   __rfloordiv__zReal.__rfloordiv__   r'   r   c                     t           )zself % otherr   r$   s     r   __mod__zReal.__mod__   r'   r   c                     t           )zother % selfr   r$   s     r   __rmod__zReal.__rmod__   r'   r   c                     t           )zRself < other

        < on Reals defines a total ordering, except perhaps for NaN.r   r$   s     r   __lt__zReal.__lt__   rJ   r   c                     t           )zself <= otherr   r$   s     r   __le__zReal.__le__   r'   r   c                 :    t          t          |                     S )z(complex(self) == complex(float(self), 0))complexfloatr   s    r   r   zReal.__complex__   s    uT{{###r   c                     | 
 S )z&Real numbers are their real component.r   r   s    r   r   z	Real.real        ur   c                     dS )z)Real numbers have no imaginary component.r   r   r   s    r   r"   z	Real.imag   	     qr   c                     | 
 S )zConjugate is a no-op for Reals.r   r   s    r   rC   zReal.conjugate  s	    ur   N)r   r   r   r   r   r   rI   rL   rN   rP   rS   rU   rW   rY   r[   r]   r_   ra   rc   r   rF   r   r"   rC   r   r   r   r   r      s         I" " ^" 
" 
" ^
" " " ^" " " ^" " " " ^"- - -- - - " " ^" " " ^" " " ^" " " ^" " " ^" " " ^"
$ $ $   X   X    r   r   c                   h    e Zd ZdZdZeed                         Zeed                         Zd Z	dS )r   z6.numerator and .denominator should be in lowest terms.r   c                     t           rl   r   r   s    r   	numeratorzRational.numerator  r'   r   c                     t           rl   r   r   s    r   denominatorzRational.denominator  r'   r   c                 T    t          | j                  t          | j                  z  S )a  float(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.

        )intro   rq   r   s    r   rI   zRational.__float__  s$     4>""S)9%:%:::r   N)
r   r   r   r   r   rF   r   ro   rq   rI   r   r   r   r   r     sv        @@I" " ^ X" " " ^ X"; ; ; ; ;r   r   c                   n   e Zd ZdZdZed             Zd Zedd            Zed             Z	ed             Z
ed	             Zed
             Zed             Zed             Zed             Zed             Zed             Zed             Zed             Zd Zed             Zed             ZdS )r	   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                     t           )z	int(self)r   r   s    r   __int__zIntegral.__int__/  r'   r   c                      t          |           S )z6Called whenever an index is needed, such as in slicing)rs   r   s    r   	__index__zIntegral.__index__4  s    4yyr   Nc                     t           )a4  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   r;   moduluss      r   r<   zIntegral.__pow__8  s
     "!r   c                     t           )zself << otherr   r$   s     r   
__lshift__zIntegral.__lshift__C  r'   r   c                     t           )zother << selfr   r$   s     r   __rlshift__zIntegral.__rlshift__H  r'   r   c                     t           )zself >> otherr   r$   s     r   
__rshift__zIntegral.__rshift__M  r'   r   c                     t           )zother >> selfr   r$   s     r   __rrshift__zIntegral.__rrshift__R  r'   r   c                     t           )zself & otherr   r$   s     r   __and__zIntegral.__and__W  r'   r   c                     t           )zother & selfr   r$   s     r   __rand__zIntegral.__rand__\  r'   r   c                     t           )zself ^ otherr   r$   s     r   __xor__zIntegral.__xor__a  r'   r   c                     t           )zother ^ selfr   r$   s     r   __rxor__zIntegral.__rxor__f  r'   r   c                     t           )zself | otherr   r$   s     r   __or__zIntegral.__or__k  r'   r   c                     t           )zother | selfr   r$   s     r   __ror__zIntegral.__ror__p  r'   r   c                     t           )z~selfr   r   s    r   
__invert__zIntegral.__invert__u  r'   r   c                 :    t          t          |                     S )zfloat(self) == float(int(self)))rf   rs   r   s    r   rI   zIntegral.__float__{  s    SYYr   c                     | 
 S )z"Integers are their own numerators.r   r   s    r   ro   zIntegral.numerator  rh   r   c                     dS )z!Integers have a denominator of 1.   r   r   s    r   rq   zIntegral.denominator  rj   r   rl   )r   r   r   r   r   r   rv   rx   r<   r|   r~   r   r   r   r   r   r   r   r   r   rI   rF   ro   rq   r   r   r   r	   r	   &  s         I" " ^"   " " " ^" " " ^" " " ^" " " ^" " " ^" " " ^" " " ^" " " ^" " " ^" " " ^" " " ^" " " ^"
        X   X  r   r	   N)r   abcr   r   __all__r   r   registerre   r   rf   r   r	   rs   r   r   r   <module>r      sn  @ @ ( ' ' ' ' ' ' '
?
?
?	 	 	 	 	w 	 	 	 	(n" n" n" n" n"f n" n" n"`      s s s s s7 s s sj e   ; ; ; ; ;t ; ; ;6a a a a ax a a aF 	  #     r   