ó
    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   é%   z“All 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   € à�q‰yÐ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   € àˆu�u‰}Ð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   é¬   zÌTo 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)z Rounds 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$ )z�divmod(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$ )z�divmod(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   € ä”u˜T“{Ó#Ð#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      -  $ )zë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.

)Ú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?  zŽIntegral 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   € ä�4‹yÐ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   