o
    fl(                     @   s   d Z ddlmZmZ g dZG dd dedZG dd deZee G d	d
 d
eZ	e	e
 G dd de	ZG d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                   @   s   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	   r	   r	   /usr/lib/python3.10/numbers.pyr      s    r   )	metaclassc                   @   s   e Zd ZdZdZedd Zdd Zeedd Z	eed	d
 Z
edd Zedd Zedd Zedd Zdd Zdd Zedd Zedd Zedd Zedd Zedd  Zed!d" Zed#d$ Zed%d& Zed'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                 C      dS )z<Return a builtin complex instance. Called for complex(self).Nr	   selfr	   r	   r   __complex__-   s    zComplex.__complex__c                 C   s   | dkS )z)True if self != 0. Called for bool(self).r   r	   r   r	   r	   r   __bool__1      zComplex.__bool__c                 C      t )zXRetrieve the real component of this number.

        This should subclass Real.
        NotImplementedErrorr   r	   r	   r   real5      zComplex.realc                 C   r   )z]Retrieve the imaginary component of this number.

        This should subclass Real.
        r   r   r	   r	   r   imag>   r   zComplex.imagc                 C   r   )zself + otherr   r   otherr	   r	   r   __add__G      zComplex.__add__c                 C   r   )zother + selfr   r   r	   r	   r   __radd__L   r!   zComplex.__radd__c                 C   r   )z-selfr   r   r	   r	   r   __neg__Q   r!   zComplex.__neg__c                 C   r   )z+selfr   r   r	   r	   r   __pos__V   r!   zComplex.__pos__c                 C   s
   | |  S )zself - otherr	   r   r	   r	   r   __sub__[      
zComplex.__sub__c                 C   s
   |  | S )zother - selfr	   r   r	   r	   r   __rsub___   r&   zComplex.__rsub__c                 C   r   )zself * otherr   r   r	   r	   r   __mul__c   r!   zComplex.__mul__c                 C   r   )zother * selfr   r   r	   r	   r   __rmul__h   r!   zComplex.__rmul__c                 C   r   )z5self / other: Should promote to float when necessary.r   r   r	   r	   r   __truediv__m   r!   zComplex.__truediv__c                 C   r   )zother / selfr   r   r	   r	   r   __rtruediv__r   r!   zComplex.__rtruediv__c                 C   r   )zBself**exponent; should promote to float or complex when necessary.r   )r   exponentr	   r	   r   __pow__w   r!   zComplex.__pow__c                 C   r   )zbase ** selfr   )r   baser	   r	   r   __rpow__|   r!   zComplex.__rpow__c                 C   r   )z7Returns the Real distance from 0. Called for abs(self).r   r   r	   r	   r   __abs__   r!   zComplex.__abs__c                 C   r   )z$(x+y*i).conjugate() returns (x-y*i).r   r   r	   r	   r   	conjugate   r!   zComplex.conjugatec                 C   r   )zself == otherr   r   r	   r	   r   __eq__   r!   zComplex.__eq__N)r
   r   r   r   r   r   r   r   propertyr   r   r    r"   r#   r$   r%   r'   r(   r)   r*   r+   r-   r/   r0   r1   r2   r	   r	   r	   r   r       sP    













r   c                   @   s   e Zd ZdZdZedd Zedd Zedd Zed	d
 Z	ed&ddZ
dd Zdd Zedd Zedd Zedd Zedd Zedd Zedd Zdd Zed d! Zed"d# Zd$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                 C   r   )zTAny Real can be converted to a native float object.

        Called for float(self).r   r   r	   r	   r   	__float__      zReal.__float__c                 C   r   )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   r	   r	   r   	__trunc__   s   zReal.__trunc__c                 C   r   )z$Finds the greatest Integral <= self.r   r   r	   r	   r   	__floor__   r!   zReal.__floor__c                 C   r   )z!Finds the least Integral >= self.r   r   r	   r	   r   __ceil__   r!   zReal.__ceil__Nc                 C   r   )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   ndigitsr	   r	   r   	__round__   r   zReal.__round__c                 C   s   | | | | fS )zdivmod(self, other): The pair (self // other, self % other).

        Sometimes this can be computed faster than the pair of
        operations.
        r	   r   r	   r	   r   
__divmod__      zReal.__divmod__c                 C   s   ||  ||  fS )zdivmod(other, self): The pair (self // other, self % other).

        Sometimes this can be computed faster than the pair of
        operations.
        r	   r   r	   r	   r   __rdivmod__   r<   zReal.__rdivmod__c                 C   r   )z)self // other: The floor() of self/other.r   r   r	   r	   r   __floordiv__   r!   zReal.__floordiv__c                 C   r   )z)other // self: The floor() of other/self.r   r   r	   r	   r   __rfloordiv__   r!   zReal.__rfloordiv__c                 C   r   )zself % otherr   r   r	   r	   r   __mod__   r!   zReal.__mod__c                 C   r   )zother % selfr   r   r	   r	   r   __rmod__   r!   zReal.__rmod__c                 C   r   )zRself < other

        < on Reals defines a total ordering, except perhaps for NaN.r   r   r	   r	   r   __lt__   r5   zReal.__lt__c                 C   r   )zself <= otherr   r   r	   r	   r   __le__   r!   zReal.__le__c                 C      t t| S )z(complex(self) == complex(float(self), 0))complexfloatr   r	   r	   r   r         zReal.__complex__c                 C      | 
 S )z&Real numbers are their real component.r	   r   r	   r	   r   r         z	Real.realc                 C   r   )z)Real numbers have no imaginary component.r   r	   r   r	   r	   r   r      r!   z	Real.imagc                 C   rH   )zConjugate is a no-op for Reals.r	   r   r	   r	   r   r1     s   zReal.conjugateN)r
   r   r   r   r   r   r4   r6   r7   r8   r:   r;   r=   r>   r?   r@   rA   rB   rC   r   r3   r   r   r1   r	   r	   r	   r   r      sB    











r   c                   @   s<   e Zd ZdZdZeedd Zeedd Zdd Z	d	S )
r   z6.numerator and .denominator should be in lowest terms.r	   c                 C   r   rJ   r   r   r	   r	   r   	numerator  r!   zRational.numeratorc                 C   r   rJ   r   r   r	   r	   r   denominator  r!   zRational.denominatorc                 C   s   t | jt | j 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.

        )intrK   rL   r   r	   r	   r   r4     s   zRational.__float__N)
r
   r   r   r   r   r3   r   rK   rL   r4   r	   r	   r	   r   r     s    r   c                   @   s   e Zd ZdZdZedd Zdd Zed&dd	Zed
d Z	edd Z
edd Zedd Zedd Zedd Zedd Zedd Zedd Zedd Zedd Zd d! Zed"d# Zed$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                 C   r   )z	int(self)r   r   r	   r	   r   __int__/  r!   zIntegral.__int__c                 C   s   t | S )z6Called whenever an index is needed, such as in slicing)rM   r   r	   r	   r   	__index__4  r   zIntegral.__index__Nc                 C   r   )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,   modulusr	   r	   r   r-   8  s   	zIntegral.__pow__c                 C   r   )zself << otherr   r   r	   r	   r   
__lshift__C  r!   zIntegral.__lshift__c                 C   r   )zother << selfr   r   r	   r	   r   __rlshift__H  r!   zIntegral.__rlshift__c                 C   r   )zself >> otherr   r   r	   r	   r   
__rshift__M  r!   zIntegral.__rshift__c                 C   r   )zother >> selfr   r   r	   r	   r   __rrshift__R  r!   zIntegral.__rrshift__c                 C   r   )zself & otherr   r   r	   r	   r   __and__W  r!   zIntegral.__and__c                 C   r   )zother & selfr   r   r	   r	   r   __rand__\  r!   zIntegral.__rand__c                 C   r   )zself ^ otherr   r   r	   r	   r   __xor__a  r!   zIntegral.__xor__c                 C   r   )zother ^ selfr   r   r	   r	   r   __rxor__f  r!   zIntegral.__rxor__c                 C   r   )zself | otherr   r   r	   r	   r   __or__k  r!   zIntegral.__or__c                 C   r   )zother | selfr   r   r	   r	   r   __ror__p  r!   zIntegral.__ror__c                 C   r   )z~selfr   r   r	   r	   r   
__invert__u  r!   zIntegral.__invert__c                 C   rD   )zfloat(self) == float(int(self)))rF   rM   r   r	   r	   r   r4   {  rG   zIntegral.__float__c                 C   rH   )z"Integers are their own numerators.r	   r   r	   r	   r   rK     rI   zIntegral.numeratorc                 C   r   )z!Integers have a denominator of 1.   r	   r   r	   r	   r   rL     r!   zIntegral.denominatorrJ   )r
   r   r   r   r   r   rN   rO   r-   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r4   r3   rK   rL   r	   r	   r	   r   r   &  sF    













r   N)r   abcr   r   __all__r   r   registerrE   r   rF   r   r   rM   r	   r	   r	   r   <module>   s   
p
uc