Your IP : 18.117.11.13


Current Path : /opt/alt/python312/lib64/python3.12/__pycache__/
Upload File :
Current File : //opt/alt/python312/lib64/python3.12/__pycache__/_pydecimal.cpython-312.opt-2.pyc

�

�Q�f�w�
��	gd�ZeZdZdZdZddlZddlZddl	Z		ddl
mZeddd�	�Z
dZdZd
ZdZdZdZdZdZdZdZe	j2dk(rdZdZdZndZdZdZeedz
z
ZGd�de�ZGd�de�Z Gd�de�Z!Gd �d!e!�Z"Gd"�d#ee#�Z$Gd$�d%e!�Z%Gd&�d'e!e#�Z&Gd(�d)e�Z'Gd*�d+e!�Z(Gd,�d-e�Z)Gd.�d/e�Z*Gd0�d1e'e)�Z+Gd2�d3e'e)e*�Z,Gd4�d5ee-�Z.e e$e'e+e)e,e!e*e.g	Z/e"e!e%e!e&e!e(e!iZ0eeeeeeeefZ1ddl2Z2e2jfd6�Z4e5gd7��Z6d8�Z7d9�Z8[2dsd:�Z9Gd;�d<e:�Z;dtd=�Z<ejzj}e;�Gd>�d?e:�Z?Gd@�dAe:�Z@GdB�dCe:�ZAdudD�ZBeCj�ZEdE�ZFdF�ZGdG�ZHdH�ZIdvdI�ZJdJ�ZKdK�ZLGdL�dMe:�ZMeM�j�ZOdvdN�ZPdO�ZQdP�ZRdQdRdSdTdUdVdWdXdYdZ�	fd[�ZSdwd\�ZTdtd]�ZUe@d^ee$e+e!ggd_d`dd�a�ZVe@dbee$e+e!e e,gg�c�ZWe@dbegg�c�ZXddlYZYeYj�ddeYj�eYj�z�j�Z^eYj�de�j�Z_eYj�df�j�Z`eYj�dgeYj�eYj�z�Zb[Y	ddlcZddsdh�Zedi�Zfdj�Zgdxdk�Zhdl�Zidm�Zje;dn�Zke;do�Zle;dp�Zme;d�Zne;d�Zoe;dq�ZpekelfZqe	j�j�Zte	j�j�Zve	j�j�ZxeydXetdrz
et�Zz[	y#e$rd
�Z
Y��DwxYw#e$rY��wxYw)y)%�Decimal�Context�DecimalTuple�DefaultContext�BasicContext�ExtendedContext�DecimalException�Clamped�InvalidOperation�DivisionByZero�Inexact�Rounded�	Subnormal�Overflow�	Underflow�FloatOperation�DivisionImpossible�InvalidContext�ConversionSyntax�DivisionUndefined�
ROUND_DOWN�
ROUND_HALF_UP�ROUND_HALF_EVEN�
ROUND_CEILING�ROUND_FLOOR�ROUND_UP�ROUND_HALF_DOWN�
ROUND_05UP�
setcontext�
getcontext�localcontext�MAX_PREC�MAX_EMAX�MIN_EMIN�	MIN_ETINY�HAVE_THREADS�HAVE_CONTEXTVAR�decimalz1.70z2.4.2�N)�
namedtuplerzsign digits exponent)�modulec��|S�N�)�argss �1/opt/alt/python312/lib64/python3.12/_pydecimal.py�<lambda>r0Cs���rrrrrrrrTl����l��N�Zol������N�Zoi@�Ti����c��eZdZ	d�Zy)rc��yr,r-��self�contextr.s   r/�handlezDecimalException.handlers��r1N��__name__�
__module__�__qualname__r8r-r1r/rr_s���$
r1rc��eZdZy)r	N�r:r;r<r-r1r/r	r	v���	r1r	c��eZdZ	d�Zy)r
c��|r9t|dj|djdd�}|j|�StS)Nr(�nT)�_dec_from_triple�_sign�_int�_fix_nan�_NaN)r6r7r.�anss    r/r8zInvalidOperation.handle�s9���"�4��7�=�=�$�q�'�,�,��T�J�C��<�<��(�(��r1Nr9r-r1r/r
r
�s���,r1r
c��eZdZ	d�Zy)rc��tSr,�rGr5s   r/r8zConversionSyntax.handle�����r1Nr9r-r1r/rr�s���r1rc��eZdZ	d�Zy)rc��t|Sr,)�_SignedInfinity�r6r7�signr.s    r/r8zDivisionByZero.handle�s
���t�$�$r1Nr9r-r1r/rr�s��
�%r1rc��eZdZ	d�Zy)rc��tSr,rKr5s   r/r8zDivisionImpossible.handle�rLr1Nr9r-r1r/rr�����r1rc��eZdZ	d�Zy)rc��tSr,rKr5s   r/r8zDivisionUndefined.handle�rLr1Nr9r-r1r/rr�rTr1rc��eZdZy)rNr>r-r1r/rr�r?r1rc��eZdZ	d�Zy)rc��tSr,rKr5s   r/r8zInvalidContext.handle�rLr1Nr9r-r1r/rr�s���r1rc��eZdZy)r
Nr>r-r1r/r
r
�r?r1r
c��eZdZy)rNr>r-r1r/rr�s��r1rc��eZdZ	d�Zy)rc��|jttttfvr	t
|S|dk(rP|jtk(r	t
|St|d|jz|j|jz
dz�S|dk(rP|jtk(r	t
|St|d|jz|j|jz
dz�Sy)Nr(�9r2)�roundingrrrrrOrrC�prec�EmaxrrPs    r/r8zOverflow.handles������
�� /�� ;�;�"�4�(�(��1�9����=�0�&�t�,�,�#�D�#�g�l�l�*:�#�L�L����5�a�7�9�
9��1�9����;�.�&�t�,�,�#�D�#�g�l�l�*:�$�\�\�'�,�,�6�q�8�:�
:�r1Nr9r-r1r/rrs���*
:r1rc��eZdZy)rNr>r-r1r/rr&���r1rc��eZdZy)rNr>r-r1r/rr5rcr1r�decimal_context)r`�Eminra�capitals�clampr_�flags�trapsc��		tj�S#t$r$t�}tj	|�|cYSwxYwr,)�_current_context_var�get�LookupErrorr�set�r7s r/rr_sD����#�'�'�)�)�����)��� � ��)����s��*A�Ac��	|tttfvr |j�}|j	�t
j
|�yr,)rrr�copy�clear_flagsrlrorps r/rrms9��/��>�<��A�A��,�,�.���������W�%r1c���	|�
t�}t|�}|j�D]3\}}|tvrt	d|�d���t|j||��5|S)N�'z2' is an invalid keyword argument for this function)r�_ContextManager�items�_context_attributes�	TypeError�setattr�new_context)�ctx�kwargs�ctx_manager�key�values     r/r r vsl��"�F�{��l��!�#�&�K��l�l�n�
��U��)�)��a��u�$V�W�X�X���'�'��e�4�%��r1c
��eZdZ	dZdyd�Zed��Zd�Zd�Zdzd�Z	d�Z
d	�Zd
�Zd{d�Z
d{d�Zd{d
�Zd{d�Zd{d�Zd{d�Zd�Zd�Zd�Zd�Zd|d�Zd{d�Zd{d�Zd{d�Zd}d�Zd{d�ZeZd{d�Zd{d�Zd{d�Z e Z!d{d�Z"d�Z#d{d �Z$d{d!�Z%d{d"�Z&d{d#�Z'd{d$�Z(d{d%�Z)d{d&�Z*d{d'�Z+d(�Z,d)�Z-e-Z.e/d*��Z0e/d+��Z1d,�Z2d-�Z3d.�Z4d/�Z5d0�Z6d1�Z7d2�Z8d3�Z9d4�Z:d5�Z;d6�Z<d7�Z=e>e6e7e8e9e:e;e<e=�8�Z?d{d9�Z@d:�ZAd;�ZBd{d<�ZCd{d=�ZDd>�ZEdzd?�ZFd{d@�ZGd{dA�ZHdzdB�ZId{dC�ZJdD�ZKdE�ZLdzdF�ZMdzdG�ZNeNZOd{dH�ZPd{dI�ZQd{dJ�ZRdK�ZSdL�ZTdM�ZUdN�ZVd{dO�ZWd{dP�ZXd{dQ�ZYdR�ZZdS�Z[d{dT�Z\d{dU�Z]dV�Z^dW�Z_dX�Z`dY�Zad{dZ�Zbd[�Zcd\�Zdd]�Zed{d^�Zfd_�Zgd`�Zhd{da�Zidb�Zjd{dc�Zkd{dd�Zlde�Zmdf�Znd{dg�Zod{dh�Zpd{di�Zqd{dj�Zrd{dk�Zsd{dl�Ztd{dm�Zud{dn�Zvd{do�Zwd{dp�Zxdq�Zyd{dr�Zzd{ds�Z{d{dt�Z|du�Z}dv�Z~dw�Zdzdx�Z�y)~r)�_exprErD�_is_specialNc�:	�	tj|�}t|t��rht	|j�j
dd��}|�%|�
t�}|jtd|z�S|jd�dk(rd|_nd|_|jd�}|�k|jd	�xsd}t|jd
�xsd�}tt||z��|_
|t|�z
|_d|_|S|jd
�}|�Mtt|xsd��j#d�|_
|jd�rd|_nd|_nd|_
d|_d|_|St|t�r=|dk\rd|_nd|_d|_tt%|��|_
d|_|St|t&�rF|j|_|j|_|j|_
|j |_|St|t(�rN|j*|_t|j�|_
t|j,�|_d|_|St|t.t0f��rZt|�dk7rt3d��t|dt�r|ddvst3d��|d|_|ddk(rd|_
|d|_d|_|Sg}	|dD]N}
t|
t�r2d|
cxkrdkr'nt3d��|	s|
dk7s�3|	j5|
��Et3d��|ddvr7dj7t9t|	��|_
|d|_d|_|St|dt�r<dj7t9t|	xsdg��|_
|d|_d|_|St3d��t|t:�r}|�
t�}|jt<d�t&j?|�}|j|_|j|_|j|_
|j |_|StAd|z��)N�_�zInvalid literal for Decimal: %rrQ�-r2r(�int�frac�exp�0F�diag�signal�NrB�FT�ztInvalid tuple size in creation of Decimal from list or tuple.  The list or tuple should have exactly three elements.�r(r2z|Invalid sign.  The first value in the tuple should be an integer; either 0 for a positive number or 1 for a negative number.��	zTThe second value in the tuple must be composed of integers in the range 0 through 9.�rBr�zUThe third value in the tuple must be an integer, or one of the strings 'F', 'n', 'N'.�;strict semantics for mixing floats and Decimals are enabledzCannot convert %r to Decimal)!�object�__new__�
isinstance�str�_parser�strip�replacer�_raise_errorr�grouprDr�rE�lenr�r��lstrip�absr�_WorkReprQr��list�tuple�
ValueError�append�join�map�floatr�
from_floatry)�clsr�r7r6�m�intpart�fracpartr�r��digits�digits           r/r�zDecimal.__new__�sQ��	�,�~�~�c�"���e�S�!�����
�-�-�c�2�6�7�A��y��?�(�l�G��+�+�,<� A�E� I�K�K��w�w�v��#�%���
���
��g�g�e�n�G��"��7�7�6�?�0�b���!�'�'�%�.�/�C�0����G�H�$4� 5�6��	��#�h�-�/��	�#(�� ��K��w�w�v����#� #�C����$4� 5� <� <�S� A�D�I��w�w�x�(�$'��	�$'��	�!$�D�I� #�D�I�#'�� ��K��e�S�!���z���
���
��D�I��C��J��D�I�$�D���K��e�W�%����D�I����D�J����D�I� %� 1� 1�D���K��e�X�&����D�J��E�I�I��D�I��E�I�I��D�I�$�D���K��e�d�5�\�*��5�z�Q�� �"G�H�H��u�Q�x��-�%��(�e�2C� �"O�P�P��q��D�J��Q�x�3����	�!�!�H��	�#'�� �6�K�1��"�1�X�E�!�%��-�!�u�/��/�
)�*8�9�9�"�U�a�Z�"�M�M�%�0�(�*8�9�9�
&���8�z�)� "����C��(8� 9�D�I� %�a��D�I�'+�D�$��K� ��a��#�.� "����C���A�3�(?� @�D�I� %�a��D�I�',�D�$�
�K�%�&>�?�?�
�e�U�#���$�,��� � ���
��&�&�u�-�E����D�I����D�J����D�I� %� 1� 1�D���K��6��>�?�?r1c��	t|t�r |dk\rdnd}d}tt|��}n�t|t�r�tj|�stj|�r|t|��Stjd|�dk(rd}nd}t|�j�\}}|j�dz
}t|d|zz�}ntd��t|||�}|tur|S||�S)Nr(r2g�?�zargument must be int or float.)r�r�r�r�r��_math�isinf�isnan�repr�copysign�as_integer_ratio�
bit_lengthryrCr)r��frQ�k�coeffrB�d�results        r/r�zDecimal.from_floatIs���	�(�a����Q��1�A�D��A���A��K�E�
��5�
!��{�{�1�~����Q���4��7�|�#��~�~�c�1�%��,������q�6�*�*�,�D�A�q������"�A���!�Q�$��K�E��<�=�=�!�$���r�2���'�>��M��v�;�r1c�N�	|jr|j}|dk(ry|dk(ryy)NrBr2r�r�r()r�r�)r6r�s  r/�_isnanzDecimal._isnanvs2��	�����)�)�C��c�z������r1c�@�	|jdk(r|jryyy)Nr����r2r()r�rD�r6s r/�_isinfinityzDecimal._isinfinity�s%��	��9�9����z�z���r1c�(�	|j�}|�d}n|j�}|s|rh|�
t�}|dk(r|jtd|�S|dk(r|jtd|�S|r|j	|�S|j	|�Sy)NFr��sNaNr()r�rr�r
rF)r6�otherr7�self_is_nan�other_is_nans     r/�_check_nanszDecimal._check_nans�s���	��k�k�m���=� �L� �<�<�>�L��,���$�,���a���+�+�,<�f�(,�.�.��q� ��+�+�,<�f�(-�/�/���}�}�W�-�-��>�>�'�*�*�r1c��	|�
t�}|js|jr�|j�r|jtd|�S|j�r|jtd|�S|j�r|jtd|�S|j�r|jtd|�Sy)Nzcomparison involving sNaNzcomparison involving NaNr()rr��is_snanr�r
�is_qnan�r6r�r7s   r/�_compare_check_nanszDecimal._compare_check_nans�s���		��?� �l�G����u�0�0��|�|�~��+�+�,<�,G�,0�2�2������+�+�,<�,G�,1�3�3������+�+�,<�,F�,0�2�2������+�+�,<�,F�,1�3�3�r1c�>�	|jxs|jdk7S�Nr��r�rEr�s r/�__bool__zDecimal.__bool__�s#��	����3�4�9�9��#3�3r1c���	|js|jr-|j�}|j�}||k(ry||kryy|s|syd|jzS|sd|jzS|j|jkry|j|jkry|j�}|j�}||k(r||jd|j
|j
z
zz}|jd|j
|j
z
zz}||k(ry||krd|jzSd|jzS||kDrd|jzSd|jzS)Nr(r�r2r�)r�r�rD�adjustedrEr�)r6r��self_inf�	other_inf�
self_adjusted�other_adjusted�self_padded�other_paddeds        r/�_cmpzDecimal._cmp�sc��	D�
���u�0�0��'�'�)�H��)�)�+�I��9�$���I�%�������u�{�{�*�+�+������#�#��;�;����#���:�:����#���
�
��
����)���N�*��)�)�c�4�9�9�u�z�z�+A�&B�B�K� �:�:��U�Z�Z�$�)�)�-C�(D�D�L��l�*���|�+��d�j�j�(�(�(��T�Z�Z�'�'�
�^�
+�����#�#��4�:�:�%�&�&r1c��t||d��\}}|tur|S|j||�ry|j|�dk(S)NT)�equality_opFr()�_convert_for_comparison�NotImplementedr�r�r�s   r/�__eq__zDecimal.__eq__sH��-�d�E�t�L���e��N�"��L����E�7�+���y�y���1�$�$r1c��t||�\}}|tur|S|j||�}|ry|j|�dkS�NFr(�r�r�r�r��r6r�r7rHs    r/�__lt__zDecimal.__lt__"�K��-�d�E�:���e��N�"��L��&�&�u�g�6�����y�y���!�#�#r1c��t||�\}}|tur|S|j||�}|ry|j|�dkSr�r�r�s    r/�__le__zDecimal.__le__+�K��-�d�E�:���e��N�"��L��&�&�u�g�6�����y�y���1�$�$r1c��t||�\}}|tur|S|j||�}|ry|j|�dkDSr�r�r�s    r/�__gt__zDecimal.__gt__4r�r1c��t||�\}}|tur|S|j||�}|ry|j|�dk\Sr�r�r�s    r/�__ge__zDecimal.__ge__=r�r1c��	t|d��}|js|r"|jr|j||�}|r|St|j	|��S�NT��raiseit)�_convert_otherr�r�rr�r�s    r/�comparezDecimal.compareFsX��	��u�d�3��
����%�*;�*;��"�"�5�'�2�C���
��t�y�y��'�(�(r1c���	|jrY|j�rtd��|j�rtj|�S|jrtStS|jdk\rtd|jt�}n tt|jt�}t|j�|ztz}|dk\r|n|}|dk(rdS|S)Nz"Cannot hash a signaling NaN value.r(�
r����)r�r�ry�is_nanr��__hash__rD�_PyHASH_INFr��pow�_PyHASH_MODULUS�
_PyHASH_10INVr�rE)r6�exp_hash�hash_rHs    r/r�zDecimal.__hash__Xs���'�����|�|�~�� D�E�E��������t�,�,��:�:�'�<�'�&�&��9�9��>��2�t�y�y�/�:�H��=�4�9�9�*�o�F�H��D�I�I���)�O�;���q�y�e�u�f���B�Y�r�'�C�'r1c	��	t|jttt|j
��|j�Sr,)rrDr�r�r�rEr�r�s r/�as_tuplezDecimal.as_tuplers0��	��D�J�J��c�#�t�y�y�.A�(B�D�I�I�N�Nr1c���	|jr&|j�rtd��td��|syt	|j
�}|jdk\r|d|jzzd}}nt|j}|dkDr |dzdk(r|dz}|dz}|dkDr	|dzdk(r�|j}t||zj�dz
|�}|r
||z}||z}d|z|z}|jr|}||fS)Nz#cannot convert NaN to integer ratioz(cannot convert Infinity to integer ratior�r(r�r2r�)
r�r�r��
OverflowErrorr�rEr��minr�rD)r6rBr��d5�d2�shift2s      r/r�zDecimal.as_integer_ratioys��	�����{�{�}� �!F�G�G�#�$N�O�O���
��	�	�N���9�9��>��r�4�9�9�}�$�a�q�A��)�)��B��q�&�Q��U�a�Z��a����a����q�&�Q��U�a�Z��)�)��B��!�q�b�&�,�,�.��2�B�7�F���f����f����2����A��:�:���A��!�t�r1c� �	dt|�zS)Nz
Decimal('%s'))r�r�s r/�__repr__zDecimal.__repr__�s��>���T��*�*r1c�
�	ddg|j}|jrG|jdk(r|dzS|jdk(r|dz|jzS|dz|jzS|jt	|j�z}|jdkr|d	kDr|}n+|sd
}n&|jdk(r|d
zdzd
z
}n|d
z
dzd
z}|dkrd}d
d|zz|jz}nd|t	|j�k\r+|jd|t	|j�z
zz}d}n!|jd|}d
|j|dz}||k(rd}n&|�
t�}ddg|jd||z
zz}||z|z|zS)Nr�r�r��InfinityrB�NaNr�r(���r2r�r��.�e�Ez%+d)rDr�r�rEr�rrg)	r6�engr7rQ�
leftdigits�dotplacer�r�r�s	         r/�__str__zDecimal.__str__�s���	�
�C�y����$������y�y�C���j�(�(����c�!��e�|�d�i�i�/�/��f�}�t�y�y�0�0��Y�Y��T�Y�Y��/�
�
�9�9��>�j�2�o�!�H���H�
�Y�Y�#�
�"�Q��!�+�a�/�H�#�Q��!�+�a�/�H��q�=��G��S�8�)�_�,�t�y�y�8�H�
��T�Y�Y��
'��i�i��X�c�$�)�)�n�%<� =�=�G��H��i�i�	��*�G��T�Y�Y�x�y�1�1�H���!��C���$�,����*�W�-�-�.��*�X�:M�1N�N�C��g�~��(�3�.�.r1c�*�	|jd|��S)NT)rr7)r�r6r7s  r/�
to_eng_stringzDecimal.to_eng_string�s��	��|�|��g�|�6�6r1c���	|jr|j|��}|r|S|�
t�}|s$|jtk7r|j�}n|j
�}|j|�S�Nrp)r�r�rr_r�copy_abs�copy_negate�_fix�r6r7rHs   r/�__neg__zDecimal.__neg__�ss��	�����"�"�7�"�3�C���
��?� �l�G���(�(�K�7��-�-�/�C��"�"�$�C��x�x�� � r1c���	|jr|j|��}|r|S|�
t�}|s$|jtk7r|j�}nt
|�}|j|�Sr)r�r�rr_rrrrrs   r/�__pos__zDecimal.__pos__sl��	�����"�"�7�"�3�C���
��?� �l�G���(�(�K�7��-�-�/�C��$�-�C��x�x�� � r1c���	|s|j�S|jr|j|��}|r|S|jr|j	|��}|S|j|��}|Sr)rr�r�rDrr )r6�roundr7rHs    r/�__abs__zDecimal.__abs__sq��	���=�=�?�"�����"�"�7�"�3�C���
��:�:��,�,�w�,�/�C��
��,�,�w�,�/�C��
r1c�>�	t|�}|tur|S|�
t�}|js|jr�|j	||�}|r|S|j�rJ|j|jk7r&|j�r|jtd�St|�S|j�rt|�St|j|j�}d}|jtk(r|j|jk7rd}|sF|sDt|j|j�}|rd}t|d|�}|j|�}|S|sUt!||j|j"z
dz
�}|j%||j�}|j|�}|S|sUt!||j|j"z
dz
�}|j%||j�}|j|�}|St'|�}t'|�}t)|||j"�\}}t'�}	|j*|j*k7r�|j,|j,k(r t|d|�}|j|�}|S|j,|j,kr||}}|j*dk(r+d|	_|j*|j*c|_|_n5d|	_n-|j*dk(rd|	_d\|_|_nd|	_|j*dk(r|j,|j,z|	_n|j,|j,z
|	_|j.|	_t|	�}|j|�}|S)Nz
-INF + INFr(r2r�)r(r()r�r�rr�r�r�rDr�r
rrr�r_rrCr�maxr`�_rescaler��
_normalizerQr�r�)
r6r�r7rHr��negativezerorQ�op1�op2r�s
          r/�__add__zDecimal.__add__.s��	��u�%���N�"��L��?� �l�G����u�0�0��"�"�5�'�2�C���
����!��:�:����,��1B�1B�1D�"�/�/�0@�,�O�O��t�}�$�� � �"��u�~�%��$�)�)�U�Z�Z�(�������{�*�t�z�z�U�[�[�/H��L��E��t�z�z�5�;�;�/�D����"�4��c�2�C��(�(�7�#�C��J���c�5�:�:����4�Q�6�7�C��.�.��g�&6�&6�7�C��(�(�7�#�C��J���c�4�9�9�w�|�|�3�A�5�6�C��-�-��W�%5�%5�6�C��(�(�7�#�C��J��t�n���u�o���c�3����5���S�����8�8�s�x�x���w�w�#�'�'�!�&�|�S�#�>���h�h�w�'���
��w�w���� ���S���x�x�1�}����%(�X�X�s�x�x�"���#�(����
�X�X��]��F�K�!'��C�H�c�h��F�K��8�8�q�=����3�7�7�*�F�J����3�7�7�*�F�J��W�W��
��f�o���h�h�w����
r1c���	t|�}|tur|S|js|jr|j||��}|r|S|j	|j�|��Sr)r�r�r�r�r+rr�s    r/�__sub__zDecimal.__sub__�sh��!��u�%���N�"��L����u�0�0��"�"�5�'�"�:�C���
��|�|�E�-�-�/��|�A�Ar1c�T�	t|�}|tur|S|j||��Sr)r�r�r-r�s   r/�__rsub__zDecimal.__rsub__�s/��!��u�%���N�"��L��}�}�T�7�}�3�3r1c��	t|�}|tur|S|�
t�}|j|jz}|js|jrx|j||�}|r|S|j
�r!|s|jtd�St|S|j
�r!|s|jtd�St|S|j|jz}|r|s t|d|�}|j|�}|S|jdk(r*t||j|�}|j|�}|S|jdk(r*t||j|�}|j|�}|St|�}t|�}t|t|j |j z�|�}|j|�}|S)Nz(+-)INF * 0z0 * (+-)INFr��1)r�r�rrDr�r�r�r�r
rOr�rCrrEr�r�r�)r6r�r7�
resultsignrH�	resultexpr)r*s        r/�__mul__zDecimal.__mul__�s���	��u�%���N�"��L��?� �l�G��Z�Z�%�+�+�-�
����u�0�0��"�"�5�'�2�C���
����!��"�/�/�0@�-�P�P�&�z�2�2�� � �"��"�/�/�0@�-�P�P�&�z�2�2��I�I��
�
�*�	��5�"�:�s�I�>�C��(�(�7�#�C��J��9�9���"�:�u�z�z�9�E�C��(�(�7�#�C��J��:�:���"�:�t�y�y�)�D�C��(�(�7�#�C��J��t�n���u�o���z�3�s�w�w����/@�+A�9�M���h�h�w����
r1c��	t|�}|turtS|�
t�}|j|jz}|js|jr�|j||�}|r|S|j
�r&|j
�r|jtd�S|j
�r	t|S|j
�r1|jtd�t|d|j��S|s/|s|jtd�S|jtd|�S|s|j|jz
}d}�nt!|j"�t!|j"�z
|j$zdz}|j|jz
|z
}t'|�}t'|�}	|dk\r*t)|j*d|zz|	j*�\}}
n*t)|j*|	j*d|zz�\}}
|
r|d	zdk(rD|dz
}n>|j|jz
}||kr |dzdk(r|dz}|dz
}||kr	|dzdk(r�t|t-|�|�}|j/|�S)
Nz(+-)INF/(+-)INFzDivision by infinityr�z0 / 0zx / 0r(r2r�r�)r�r�rrDr�r�r�r�r
rOr	rC�Etinyrrr�r�rEr`r��divmodr�r�r)r6r�r7rQrHr�r��shiftr)r*�	remainder�	ideal_exps            r/�__truediv__zDecimal.__truediv__�sJ��"��u�%���N�"�!�!��?� �l�G��z�z�E�K�K�'�����u�0�0��"�"�5�'�2�C���
����!�e�&7�&7�&9��+�+�,<�>O�P�P����!�&�t�,�,�� � �"��$�$�W�.D�E�'��c�7�=�=�?�C�C����+�+�,=�w�G�G��'�'����F�F���)�)�e�j�j�(�C��E���
�
�O�c�$�)�)�n�4�w�|�|�C�a�G�E��)�)�e�j�j�(�5�0�C��4�.�C��5�/�C���z�#)�#�'�'�B��I�*=�s�w�w�#G� ��y�#)�#�'�'�3�7�7�R�%��Z�3G�#H� ��y���1�9��>��Q�J�E�!�I�I��
�
�2�	��I�o�%�"�*��/��b�L�E��1�H�C��I�o�%�"�*��/��t�S��Z��5���x�x�� � r1c��	|j|jz}|j�r
|j}n t|j|j�}|j	�|j	�z
}|r|j�s|dkr)t|dd�|j
||j�fS||jkr�t|�}t|�}|j|jk\r0|xjd|j|jz
zzc_n/|xjd|j|jz
zzc_t|j|j�\}}	|d|jzkr6t|t|�d�t|jt|	�|�fS|jtd�}
|
|
fS)Nr�r�r(r�z%quotient too large in //, % or divmod)rDr�r�rr�rCr&r_r`r�r�r�r7r�r�r)r6r�r7rQr:�expdiffr)r*�q�rrHs           r/�_dividezDecimal._divides���	�
�z�z�E�K�K�'�������	�	�I��D�I�I�u�z�z�2�I��-�-�/�E�N�N�$4�4���u�(�(�*�g��m�$�T�3��2��M�M�)�W�-=�-=�>�@�
@��g�l�l�"��4�.�C��5�/�C��w�w�#�'�'�!����2����#�'�'� 1�2�2�����2����#�'�'� 1�2�2���#�'�'�3�7�7�+�D�A�q��2�w�|�|�#�#�(��s�1�v�q�9�(����S��V�Y�G�I�I��"�"�#5�#J�L���C�x�r1c�T�	t|�}|tur|S|j||��Sr)r�r�r;r�s   r/�__rtruediv__zDecimal.__rtruediv__1s2��7��u�%���N�"��L�� � ��w� �7�7r1c�D�	t|�}|tur|S|�
t�}|j||�}|r||fS|j|jz}|j�rI|j�r|j
td�}||fSt||j
td�fS|sI|s|j
td�}||fS|j
td|�|j
td�fS|j||�\}}|j|�}||fS)Nzdivmod(INF, INF)�INF % xzdivmod(0, 0)�x // 0�x % 0)
r�r�rr�rDr�r�r
rOrrr@r)r6r�r7rHrQ�quotientr9s       r/�
__divmod__zDecimal.__divmod__8s:��	��u�%���N�"��L��?� �l�G����u�g�.�����:���z�z�E�K�K�'������� � �"��*�*�+;�=O�P���C�x��'��-��,�,�-=�y�I�K�K����*�*�+<�n�M���C�x���,�,�^�X�t�L��,�,�-=�w�G�I�I�#�l�l�5�'�:���)��N�N�7�+�	���"�"r1c�T�	t|�}|tur|S|j||��Sr)r�r�rHr�s   r/�__rdivmod__zDecimal.__rdivmod__\s2��6��u�%���N�"��L�����g��6�6r1c�n�	t|�}|tur|S|�
t�}|j||�}|r|S|j	�r|jtd�S|s.|r|jtd�S|jtd�S|j||�d}|j|�}|S)NrDrFz0 % 0r2)
r�r�rr�r�r�r
rr@r)r6r�r7rHr9s     r/�__mod__zDecimal.__mod__cs���	��u�%���N�"��L��?� �l�G����u�g�.����J������'�'�(8�)�D�D����+�+�,<�g�F�F��+�+�,=�w�G�G��L�L���0��3�	��N�N�7�+�	��r1c�T�	t|�}|tur|S|j||��Sr)r�r�rLr�s   r/�__rmod__zDecimal.__rmod__~�/��3��u�%���N�"��L��}�}�T�7�}�3�3r1c�v�	|�
t�}t|d��}|j||�}|r|S|j�r|j	t
d�S|s.|r|j	t
d�S|j	td�S|j�rt|�}|j|�St|j|j�}|s(t|jd|�}|j|�S|j�|j�z
}||jdzk\r|j	t�S|dkr-|j!||j"�}|j|�St%|�}t%|�}|j&|j&k\r0|xj(d	|j&|j&z
zzc_n/|xj(d	|j&|j&z
zzc_t+|j(|j(�\}}	d
|	z|dzz|j(kDr|	|j(z}	|dz
}|d	|jzk\r|j	t�S|j}
|	dkrd|
z
}
|	}	t|
t-|	�|�}|j|�S)NTr�zremainder_near(infinity, x)zremainder_near(x, 0)zremainder_near(0, 0)r�r2r�r�r�r()rr�r�r�r�r
rrrrr�rCrDr�r`rr&r_r�r�r�r7r�)r6r�r7rH�ideal_exponentr=r)r*r>r?rQs           r/�remainder_nearzDecimal.remainder_near�s~��	��?� �l�G��u�d�3�����u�g�.����J������'�'�(8�(E�G�
G����+�+�,<�,B�D�D��+�+�,=�,B�D�D������$�-�C��8�8�G�$�$��T�Y�Y��
�
�3���"�4�:�:�s�N�C�C��8�8�G�$�$��-�-�/�E�N�N�$4�4���g�l�l�Q�&�&��'�'�(:�;�;��b�=��-�-���0@�0@�A�C��8�8�G�$�$��t�n���u�o���7�7�c�g�g���G�G�r�C�G�G�c�g�g�-�.�.�G��G�G�r�C�G�G�c�g�g�-�.�.�G��c�g�g�s�w�w�'���1�
�Q�3�!�A�#�;���� �
����L�A�
��F�A���G�L�L� � ��'�'�(:�;�;��z�z���q�5��T�6�D���A��t�S��V�^�<���x�x�� � r1c���	t|�}|tur|S|�
t�}|j||�}|r|S|j	�rF|j	�r|jtd�St|j|jzS|sF|r.|jtd|j|jz�S|jtd�S|j||�dS)Nz
INF // INFrEz0 // 0r()r�r�rr�r�r�r
rOrDrrr@r�s    r/�__floordiv__zDecimal.__floordiv__�s�����u�%���N�"��L��?� �l�G����u�g�.����J������ � �"��+�+�,<�l�K�K�&�t�z�z�E�K�K�'?�@�@����+�+�N�H�,0�J�J����,D�F�F��+�+�,=�x�H�H��|�|�E�7�+�A�.�.r1c�T�	t|�}|tur|S|j||��Sr)r�r�rTr�s   r/�
__rfloordiv__zDecimal.__rfloordiv__�s2��8��u�%���N�"��L��!�!�$��!�8�8r1c��	|j�r6|j�rtd��|jrdnd}t|�St	|�}t|�S)Nz%Cannot convert signaling NaN to floatz-nan�nan)r�r�r�rDr�r��r6�ss  r/�	__float__zDecimal.__float__�sO��#��;�;�=��|�|�~� �!H�I�I��*�*��%�A��Q�x���D�	�A��Q�x�r1c�f�	|jr6|j�rtd��|j�rt	d��d|j
z}|jdk\r(|t|j�zd|jzzS|t|jd|jxsd�zS)NzCannot convert NaN to integerz"Cannot convert infinity to integerr�r(r�r�)	r�r�r�r�rrDr�r�rErYs  r/�__int__zDecimal.__int__�s���?�����{�{�}� �!@�A�A��!�!�#�#�$H�I�I�
�$�*�*����9�9��>��S����^�#�B��	�	�M�1�1��S����:�D�I�I�.�5�#�6�6�6r1c��|Sr,r-r�s r/�realzDecimal.reals���r1c��td�S�Nr(�rr�s r/�imagzDecimal.imags���q�z�r1c��|Sr,r-r�s r/�	conjugatezDecimal.conjugates���r1c�*�tt|��Sr,)�complexr�r�s r/�__complex__zDecimal.__complex__s���u�T�{�#�#r1c��	|j}|j|jz
}t|�|kDrB|t|�|z
dj	d�}t|j||jd�St|�S)Nr�T)	rEr`rhr�r�rCrDr�r)r6r7�payload�max_payload_lens    r/rFzDecimal._fix_nansr��@��)�)��"�,�,����6���w�<�/�)��c�'�l�?�:�;�<�C�C�C�H�G�#�D�J�J�����D�I�I��t�}�r1c���	|jr,|j�r|j|�St|�S|j	�}|j�}|s�|j|g|j}tt|j|�|�}||jk7r,|jt�t|jd|�St|�St|j �|jz|j"z
}||kDrM|jt$d|j�}|jt&�|jt(�|S||k}|r|}|j|k�rlt|j �|jz|z
}	|	dkrt|jd|dz
�}d}	|j*|j,}
|
||	�}|j d|	xsd}|dkDr9t/t1|�dz�}t|�|j"kDr
|dd}|dz
}||kDr"|jt$d|j�}nt|j||�}|r|r|jt2�|r|jt4�|r|jt&�|jt(�|s|jt�|S|r|jt4�|jdk(rZ|j|kDrK|jt�|j d|j|z
zz}
t|j|
|�St|�S)Nr��
above Emaxr(r1r2r�)r�r�rFrr6�Etoprarhrr%r�r�r	rCrDr�rEr`rrr
�_pick_rounding_functionr_r�r�rr)r6r7r6rn�exp_max�new_exp�exp_minrH�self_is_subnormalr��rounding_method�changedr�r�s              r/rzDecimal._fix&s���	�����{�{�}��}�}�W�-�-��t�}�$��
�
����|�|�~����|�|�T�*�7�=�=�9�G��#�d�i�i��/��9�G��$�)�)�#��$�$�W�-�'��
�
�C��A�A��t�}�$��d�i�i�.�4�9�9�,�w�|�|�;���T�>��&�&�x��t�z�z�J�C�� � ��)�� � ��)��J�#�e�O����G��9�9�w������^�d�i�i�/�'�9�F���z�'��
�
�C����C����"�:�:�7�;K�;K�L�O�%�d�F�3�G��I�I�g�v�&�-�#�E���{��C��J�q�L�)���u�:����,�!�#�2�J�E��q�L�G���~��*�*�8�\�4�:�:�N��&�t�z�z�5�'�B���,��$�$�Y�/� ��$�$�Y�/���$�$�W�-�� � ��)���$�$�W�-��J��� � ��+��=�=�A��$�)�)�d�"2�� � ��)��)�)�c�4�9�9�t�+;�&<�<�K�#�D�J�J��T�B�B��t�}�r1c�4�	t|j|�ryy)Nr(r�)�
_all_zerosrE�r6r`s  r/�_round_downzDecimal._round_down�s��6��d�i�i��&��r1c�(�	|j|�Sr,)ryrxs  r/�	_round_upzDecimal._round_up�s��!�� � ��&�&�&r1c�X�	|j|dvryt|j|�ryy)N�56789r2r(r�)rErwrxs  r/�_round_half_upzDecimal._round_half_up�s,��'��9�9�T�?�g�%��
��	�	�4�
(��r1c�T�	t|j|�ry|j|�S)Nr���_exact_halfrEr~rxs  r/�_round_half_downzDecimal._round_half_down�s'����t�y�y�$�'���&�&�t�,�,r1c��	t|j|�r|dk(s|j|dz
dvry|j|�S)Nr(r2�02468r�r�rxs  r/�_round_half_evenzDecimal._round_half_even�sB��/��t�y�y�$�'����d�i�i��Q��/�7�:���&�&�t�,�,r1c�b�	|jr|j|�S|j|�Sr,�rDryrxs  r/�_round_ceilingzDecimal._round_ceiling�s1��6��:�:��#�#�D�)�)��$�$�T�*�*�*r1c�b�	|js|j|�S|j|�Sr,r�rxs  r/�_round_floorzDecimal._round_floor�s1��5��z�z��#�#�D�)�)��$�$�T�*�*�*r1c�v�	|r%|j|dz
dvr|j|�S|j|�S)Nr2�05)rEryrxs  r/�_round_05upzDecimal._round_05up�sA��7��D�I�I�d�1�f�%�T�1��#�#�D�)�)��$�$�T�*�*�*r1)rrrrrrrrc��	|�:t|t�std��tdd|�}|j	|�S|j
r&|j
�rtd��td��t|jdt��S)Nz+Second argument to round should be integralr(r1�cannot round a NaN�cannot round an infinity)r�r�ryrC�quantizer�r�r�rr&r)r6rBr�s   r/�	__round__zDecimal.__round__�s���-	�\
�=��a��%�� M�N�N�"�1�c�A�2�.�C��=�=��%�%�����{�{�}� �!5�6�6�#�$>�?�?��4�=�=��O�4�5�5r1c��	|jr&|j�rtd��td��t	|jdt��S�Nr�r�r()r�r�r�rr�r&rr�s r/�	__floor__zDecimal.__floor__
sI��	�����{�{�}� �!5�6�6�#�$>�?�?��4�=�=��K�0�1�1r1c��	|jr&|j�rtd��td��t	|jdt��Sr�)r�r�r�rr�r&rr�s r/�__ceil__zDecimal.__ceil__sI��	�����{�{�}� �!5�6�6�#�$>�?�?��4�=�=��M�2�3�3r1c	��	t|d��}t|d��}|js
|j�r
|�
t�}|jdk(r|j	t
d|�S|jdk(r|j	t
d|�S|jdk(r|}�n|jdk(r|}n�|jdk(r9|s|j	t
d�St|j|jz}n�|jdk(r�|s|j	t
d�St|j|jz}nmt|j|jztt|j�t|j�z�|j|jz�}j||�S)	NTr�r�r�rBr�zINF * 0 in fmaz0 * INF in fma)
r�r�rr�r�r
rOrDrCr�r�rEr+)r6r��thirdr7�products     r/�fmazDecimal.fma+s���	��u�d�3���u�d�3�����u�0�0���$�,���y�y�C���+�+�,<�f�d�K�K��z�z�S� ��+�+�,<�f�e�L�L��y�y�C�������s�"������c�!��"�/�/�0@�0@�B�B�)�$�*�*�u�{�{�*B�C�����s�"��"�/�/�0@�0@�B�B�)�$�*�*�u�{�{�*B�C��&�t�z�z�E�K�K�'?�'*�3�t�y�y�>�C��
�
�O�+K�'L�'+�y�y�5�:�:�'=�?�G����u�g�.�.r1c�D�	t|�}|tur|St|�}|tur|S|�
t�}|j�}|j�}|j�}|s|s|r�|dk(r|j	t
d|�S|dk(r|j	t
d|�S|dk(r|j	t
d|�S|r|j
|�S|r|j
|�S|j
|�S|j�r |j�r|j�s|j	t
d�S|dkr|j	t
d�S|s|j	t
d�S|j�|jk\r|j	t
d�S|s|s|j	t
d�S|j�rd}n|j}tt|��}t|j��}t|j��}	|j|zt!d	|j"|�z|z}t%|	j"�D]}
t!|d	|�}�t!||	j|�}t'|t)|�d�S)
Nr�r�z@pow() 3rd argument not allowed unless all arguments are integersr(zApow() 2nd argument cannot be negative when 3rd argument specifiedzpow() 3rd argument cannot be 0zSinsufficient precision: pow() 3rd argument must not have more than precision digitszXat least one of pow() 1st argument and 2nd argument must be nonzero; 0**0 is not definedr�)r�r�rr�r�r
rF�
_isintegerr�r`�_isevenrDr�r�r��to_integral_valuer�r��rangerCr�)r6r��modulor7r�r��
modulo_is_nanrQ�base�exponent�is           r/�
_power_modulozDecimal._power_moduloWs���/��u�%���N�"��L���'���^�#��M��?� �l�G��k�k�m���|�|�~���
�
��
��,�-��a���+�+�,<�f�(,�.�.��q� ��+�+�,<�f�(-�/�/���!��+�+�,<�f�(.�0�0���}�}�W�-�-���~�~�g�.�.��?�?�7�+�+����!�� � �"��!�!�#��'�'�(8�)L�M�
M��1�9��'�'�(8�)O�P�
P���'�'�(8�(H�J�
J�
�?�?�����,��'�'�(8�);�<�
<��T��'�'�(8�)>�?�
?��=�=�?��D��:�:�D��S��[�!����.�.�0�1���E�3�3�5�6�����6�!�C��D�H�H�f�$=�=��G���x�|�|�$�A��t�R��(�D�%��4����v�.����c�$�i��3�3r1c��	t|�}|j|j}}|dzdk(r|dz}|dz
}|dzdk(r�t|�}|j|j}}|dzdk(r|dz}|dz
}|dzdk(r�|dk(r�||z}|dzdk(r|dz}|dz
}|dzdk(r�|dkry|d|zz}	|jdk(r|	}	|j	�r:|j
dk(r+|jt|�z}
t|	|
z
|dz
�}nd}tddd|zz|	|z
�S|jdk(�r3|dz}|dvrg||z|k7ryt|�dz
}
|dzdz}|tt|��k\ryt|
|z|�}
t||z|�}|
�|�y|
|kDryd	|
z}n�|d	k(r�t|�d
zdz}
td	|
z|�\}}|ry|d	zdk(r|d	z}|
dz}
|d	zdk(r�|dzdz}|tt|��k\ryt|
|z|�}
t||z|�}|
�|�y|
|kDryd|
z}nyt|�}t|�|kDry|
|z
}td||�S|dk\r|d|zzd}}n�|dk7r%ttt||z���|kryt|�}ttt|�|z��|kry|d|z}}|dz|dzcxk(rdk(r!nn|dz}|dz}|dz|dzcxk(rdk(r�n|d	z|d	zcxk(rdk(r!nn|d	z}|d	z}|d	z|d	zcxk(rdk(r�n|dkDrf|kryt||�\}}|dk7rydt|�|zz}	t|||dz
z�\}}||krn||dz
z|z|z}�*||k(r|dk(sy|}|dkDr||d
zt|�zkDry||z}||z}t|�}t|�|kDry|j	�rC|j
dk(r4|jt|�z}
t||
z
|t|�z
�}nd}td|d|zz||z
�S)Nr�r(r2r1r�)r�����]�Ar��r�r��d)r�r�r�rQr�rDr�rrC�_nbitsr�r��_decimal_lshift_exactr7r��	_log10_lb)r6r��p�x�xc�xe�y�yc�yer�rQ�zeros�
last_digitr�emaxr9�strxcr�rB�xc_bits�rem�ar>r?�str_xcs                         r/�_power_exactzDecimal._power_exact�s-��	B�r
�T�N��������B���2�g��l��2�I�B��!�G�B��2�g��l�
�U�O��������B���2�g��l��2�I�B��!�G�B��2�g��l���7��"�H�B��r�'�Q�,��r�	���a����r�'�Q�,��A�v���B��F�{�H��v�v��{�$�9�����!�e�k�k�Q�&6�!%���3�u�:�!5���H�^�3�Q�q�S�9����#�A�s�S��Y�����G�G�
�6�6�Q�;��b��J��Y�&����8�r�>���2�J�q�L��6��t�R�x����S��Y��'��*�!�b�&�"�5��*�2��7�B�7���9��
���t�8����T���q���2�J�r�M�2�%�� &�q�!�t�R� 0�
��I����1�f��k��1�H�B���F�A��1�f��k���t�Q�w����S��Y��'��)�!�b�&�"�5��*�2��7�B�7���9��
���t�8����T�����G�E��5�z�A�~����B��B�#�A�u�b�1�1���7��b�"�f�9�a�q�A��Q�w�3�s�3�r�"�u�:��/�B�3�6���R�j�G��3�s�2�w�w��'�(�R�C�/���r�R�C�y�q�A��a�%�1�q�5�%�A�%��a����a����a�%�1�q�5�%�A�%��a�%�1�q�5�%�A�%��a����a����a�%�1�q�5�%�A�%�

�q�5��!�|���R��m�G�B���a�x����r�
�{�A�~�&�&�A���b�!�a��c�(�+���1���6���A�a�C��1��q�(�A����F�q�A�v���B���6�a�!�C�%��2��.�.��
��U��
�a����R����v�;��?��
����%�+�+��"2�!�Y�Y�s�5�z�1�N���>�)�1�S��[�=�9�E��E���6�#�e�)�#3�R��X�>�>r1c�\�	|�|j|||�St|�}|tur|S|�
t�}|j	||�}|r|S|s|s|jtd�StSd}|jdk(rK|j�r|j�sd}n|r|jtd�S|j�}|s%|jdk(r
t|dd�St|S|j�r%|jdk(r	t|St|dd�S|tk(r�|j�r|jdk(rd}n'||jkDr
|j}nt!|�}|j"|z}|d|jz
kr^d|jz
}|jt$�n9|jt&�|jt$�d|jz
}t|dd|zz|�S|j)�}|j�r+|jdk(|dkk(r
t|dd�St|Sd}d}	|j+�|j)�z}
|dk\|jdk(k(r<|
t-t/|j0��k\rSt|d|j0dz�}n8|j3�}|
t-t/|��k\rt|d|dz
�}|�I|j5||jdz�}|�(|dk(r!td|j6|j"�}d}	|��|j}t9|�}
|
j |
j:}}t9|�}|j |j:}}|j<dk(r|}d	}	t?||||||z�\}}|d
dt-t/|��|z
dz
zzzrn|d	z
}�?t|t/|�|�}|	�r�|j��szt-|j6�|jkrY|jdzt-|j6�z
}t|j|j6d|zz|j"|z
�}|jA�}|jC�tDD]}d|jF|<�|jI|�}|jt&�|jJtLr|jtN�|jJtPr!|jtPd|j�tNtLt&t$tRfD]#}|jJ|s�|j|��%|S|jI|�}|S)
Nz0 ** 0r(r2z+x ** y with x negative and y not an integerr�r1FTr�r�r�rm)*r�r�r�rr�r�r
�_OnerDr�r�rrCrOr�r`r�r�r
rr��_log10_exp_boundr�r�rar6r�rEr�r�rQ�_dpowerrrrs�_signalsrjrrirrrr	)r6r�r�r7rH�result_sign�
multiplierr��self_adj�exact�boundr6r�r�r�r�r�r�r��extrar�r=�
newcontext�	exceptions                        r/�__pow__zDecimal.__pow__�sC��	�.���%�%�e�V�W�=�=��u�%���N�"��L��?� �l�G����u�g�.����J����+�+�,<�h�G�G������:�:��?����!��}�}��"#�K��"�/�/�0@�E�G�G��#�#�%�D���{�{�a��'��S�!�<�<�&�{�3�3������{�{�a��&�{�3�3�'��S�!�<�<�
�4�<����!�
�;�;�!�#�!"�J��W�\�\�)�!(���J�!$�U��J��i�i�*�,����7�<�<��'��G�L�L�.�C��(�(��1��$�$�W�-��$�$�W�-�����n��#�K��S�#��X��s�C�C��=�=�?���������q� �h��l�3�'��S�!�<�<�&�{�3�3������%�%�'�%�.�.�*:�:����M�u�{�{�a�/�0���C����-�.�.�&�{�C����a��H���M�M�O�E���C���K�(�(�&�{�C��q��A���;��#�#�E�7�<�<�!�+;�<�C����!�#�*�1�c�h�h����A�C����;����A����A��U�U�A�E�E��B����A��U�U�A�E�E��B��v�v��{��S���E��$�R��R��Q�u�W�=�
��s��A�b�3�s�5�z�?�1�#4�Q�#6�7�7�8����
��	�#�;��E�
�C�@�C���)�)�+��3�8�8�}����,�!�,�,��*�S����]�:��&�s�y�y�#�(�(�3�w�;�2F�'*�x�x��'7�9��!����J��"�"�$�%�	�./�
� � ��+�&��(�(�:�&�C�
�#�#�G�,����	�*��'�'�	�2�����)��$�$�X�|�S�Y�Y�G�&�	�7�G�W�L�	��#�#�I�.��(�(��3�M��
��(�(�7�#�C��
r1c�T�	t|�}|tur|S|j||��Sr)r�r�r�r�s   r/�__rpow__zDecimal.__rpow__|	rOr1c�2�	|�
t�}|jr|j|��}|r|S|j|�}|j	�r|S|st|jdd�S|j|j�g|j}t|j�}|j}|j|dz
dk(r*||kr%|dz
}|dz}|j|dz
dk(r||kr�%t|j|jd||�S)Nrpr�r(r2)
rr�r�rr�rCrDrarnrhr�rEr�)r6r7rH�duprp�endr�s       r/�	normalizezDecimal.normalize�	s��M��?� �l�G�����"�"�7�"�3�C���
��i�i�� ���?�?���J��#�C�I�I�s�A�6�6��<�<�����0����?���#�(�(�m���h�h���h�h�s�1�u�o��$��w���1�H�C��1�H�C��h�h�s�1�u�o��$��w�� ��	�	�3�8�8�D�S�>�3�?�?r1c�b�	t|d��}|�
t�}|�|j}|js|jrw|j	||�}|r|S|j�s|j�rA|j�r|j�rt
|�S|jtd�S|j�|jcxkr|jksn|jtd�S|s2t|jd|j�}|j|�S|j�}||jkDr|jtd�S||jz
dz|j kDr|jtd�S|j#|j|�}|j�|jkDr|jtd�St%|j&�|j kDr|jtd�S|r2|j�|j(kr|jt*�|j|jkDr/||k7r|jt,�|jt.�|j|�}|S)	NTr�zquantize with one INFz)target exponent out of bounds in quantizer�z9exponent of quantize result too large for current contextr2z7quantize result has too many digits for current context)r�rr_r�r�r�rr�r
r6r�rarCrDrr�r`r&r�rErfrrr
)r6r�r_r7rHr�s      r/r�zDecimal.quantize�	sQ��	��S�$�/���?� �l�G����'�'�H����s����"�"�3��0�C���
���� �D�$4�$4�$6��?�?�$��)9�)9�);�"�4�=�(��+�+�,<�(?�A�A��
�
��3�8�8�;�w�|�|�;��'�'�(8�>�@�
@��"�4�:�:�s�C�H�H�=�C��8�8�G�$�$��
�
��
��7�<�<�'��'�'�(8�(c�e�
e��3�8�8�#�a�'�'�,�,�6��'�'�(8�(a�c�
c��m�m�C�H�H�h�/���<�<�>�G�L�L�(��'�'�(8�(c�e�
e��s�x�x�=�7�<�<�'��'�'�(8�(a�c�
c��3�<�<�>�G�L�L�0�� � ��+��8�8�d�i�i���d�{��$�$�W�-�� � ��)��h�h�w����
r1c��	t|d��}|js|jrF|j�xr|j�xs"|j�xr|j�S|j|jk(Sr�)r�r�r��is_infiniter�r�s   r/�same_quantumzDecimal.same_quantum�	sr��	��u�d�3�����u�0�0��K�K�M�4�e�l�l�n�?��$�$�&�>�5�+<�+<�+>�
@��y�y�E�J�J�&�&r1c�2�	|jrt|�S|st|jd|�S|j|k\r4t|j|j
d|j|z
zz|�St
|j
�|jz|z
}|dkrt|jd|dz
�}d}|j|}|||�}|j
d|xsd}|dk(rtt|�dz�}t|j||�S)Nr�r(r1r2)
r�rrCrDr�rEr�ror�r�)r6r�r_r��
this_functionrur�s       r/r&zDecimal._rescale�	s
��		�����4�=� ��#�D�J�J��S�9�9��9�9���#�D�J�J�(,�	�	�C����S��4I�(I�3�P�
P�
�T�Y�Y��$�)�)�+�c�1���A�:�#�D�J�J��S��U�;�D��F��4�4�X�>�
���f�-���	�	�'�6�"�)�c���a�<���E�
�1��%�E���
�
�E�3�7�7r1c�4�	|dkrtd��|js|st|�S|j|j	�dz|z
|�}|j	�|j	�k7r&|j|j	�dz|z
|�}|S)Nr(z'argument should be at least 1 in _roundr2)r�r�rr&r�)r6�placesr_rHs    r/�_roundzDecimal._round

s���	��Q�;��F�G�G����4��4�=� ��m�m�D�M�M�O�A�-�f�4�h�?��
�<�<�>�T�]�]�_�,��,�,�s�|�|�~�a�/��6��A�C��
r1c�~�	|jr!|j|��}|r|St|�S|jdk\rt|�S|st	|j
dd�S|�
t
�}|�|j}|jd|�}||k7r|jt�|jt�|S)Nrpr(r�)r�r�rr�rCrDrr_r&r�rr
�r6r_r7rHs    r/�to_integral_exactzDecimal.to_integral_exact!
s���	�����"�"�7�"�3�C���
��4�=� ��9�9��>��4�=� ��#�D�J�J��Q�7�7��?� �l�G����'�'�H��m�m�A�x�(���$�;�� � ��)����W�%��
r1c���	|�
t�}|�|j}|jr!|j|��}|r|St	|�S|j
dk\rt	|�S|j
d|�S)Nrpr()rr_r�r�rr�r&r�s    r/r�zDecimal.to_integral_value>
sv��N��?� �l�G����'�'�H�����"�"�7�"�3�C���
��4�=� ��9�9��>��4�=� ��=�=��H�-�-r1c�.�	|�
t�}|jr@|j|��}|r|S|j�r|jdk(rt|�S|s5t
|jd|jdz�}|j|�S|jdk(r|jtd�S|jdz}t|�}|jdz	}|jdzr+|jdz}t|j �dz	dz}n'|j}t|j �dzdz	}||z
}|dk\r|d|zz}d	}	nt#|d|z�\}}
|
}	||z}d|z}	||z}||krn	||zdz	}�|	xr||z|k(}	|	r|dk\r	|d|zz}n	|d|zz}||z
}n
|d
zdk(r|dz
}t
dt%|�|�}|j'�}|j)t*�}
|j|�}|
|_|S)Nrpr(r�r�r2zsqrt(-x), x > 0r�r�Tr�)rr�r�r�rDrrCr�rr�r
r`r�r�r�r�rEr7r��
_shallow_copy�
_set_roundingrr_)r6r7rHr`�opr�c�lr8r�r9rBr>r_s              r/�sqrtzDecimal.sqrtQ
s:��-��?� �l�G�����"�"�7�"�3�C���
����!�d�j�j�A�o��t�}�$��"�4�:�:�s�D�I�I��N�C�C��8�8�G�$�$��:�:��?��'�'�(8�:K�L�L�,�|�|�A�~���d�^���F�F�a�K��
�6�6�A�:������A��T�Y�Y��1�$��)�A����A��D�I�I��q� �A�%�A��Q����A�:�
��e��O�A��E�!�!�S�5�&�[�1�L�A�y�!�M�E�	�U�
��
��H����1��A��A�v����E�Q�J����"�!�A�#��(�����z��b�%�i����R�%��Z���
��J�A��1�u��z��Q����q�#�a�&�!�,���'�'�)���(�(��9���h�h�w���#����
r1c���	t|d��}|�
t�}|js|jrl|j�}|j�}|s|rH|dk(r|dk(r|j	|�S|dk(r|dk(r|j	|�S|j||�S|j
|�}|dk(r|j|�}|dk(r|}n|}|j	|�S�NTr�r2r(r��r�rr�r�rr�r��
compare_total�r6r�r7�sn�onr�rHs       r/r%zDecimal.max�
s���	�
�u�d�3���?� �l�G����u�0�0�����B�����B��R���7�r�Q�w��9�9�W�-�-���7�r�Q�w� �:�:�g�.�.��'�'��w�7�7��I�I�e�����6��"�"�5�)�A���7��C��C��x�x�� � r1c���	t|d��}|�
t�}|js|jrl|j�}|j�}|s|rH|dk(r|dk(r|j	|�S|dk(r|dk(r|j	|�S|j||�S|j
|�}|dk(r|j|�}|dk(r|}n|}|j	|�Sr�r�r�s       r/rzDecimal.min�
s���	�
�u�d�3���?� �l�G����u�0�0�����B�����B��R���7�r�Q�w��9�9�W�-�-���7�r�Q�w� �:�:�g�.�.��'�'��w�7�7��I�I�e�����6��"�"�5�)�A���7��C��C��x�x�� � r1c��	|jry|jdk\ry|j|jd}|dt|�zk(S)NFr(Tr�)r�r�rEr�)r6�rests  r/r�zDecimal._isintegersF��0������9�9��>���y�y�����$���s�3�t�9�}�$�$r1c�d�	|r|jdkDry|jd|jzdvS)Nr(Tr�r�)r�rEr�s r/r�zDecimal._iseven	s1��H��t�y�y�1�}���y�y��D�I�I��&�'�1�1r1c�n�		|jt|j�zdz
S#t$rYywxYw)Nr2r()r�r�rEryr�s r/r�zDecimal.adjusteds8��2�	��9�9�s�4�9�9�~�-��1�1���	��	�s�$(�	4�4c��	|Sr,r-r�s r/�	canonicalzDecimal.canonicals��	�
�r1c�p�	t|d��}|j||�}|r|S|j||��S�NTr�rp)r�r�r�r�s    r/�compare_signalzDecimal.compare_signalsB��	�
�u��5���&�&�u�g�6����J��|�|�E�7�|�3�3r1c�d�	t|d��}|jr|jstS|js|jrtS|j}|j	�}|j	�}|s|r�||k(rnt|j�|jf}t|j�|jf}||kr|rtStS||kDr|rtStStS|r,|dk(rtS|dk(rtS|dk(rtS|dk(r2tS|dk(rtS|dk(rtS|dk(rtS|dk(rtS||krtS||kDrtS|j|jkr|rtStS|j|jkDr|rtStStS)NTr�r2r�)	r�rD�_NegativeOner�r�r�rE�_Zeror�)r6r�r7rQ�self_nan�	other_nan�self_key�	other_keys        r/r�zDecimal.compare_total+s���	��u�d�3���:�:�e�k�k����z�z�e�k�k��K��z�z���;�;�=���L�L�N�	��y��9�$��t�y�y�>�4�9�9�4����
�
�O�U�Z�Z�7�	��i�'��#��+�+��i�'��+�+�#������q�=�'�'���>��K��q�=�'�'���>��K��q�=��K���>�'�'��q�=��K���>�'�'��%�<����%�<��K��9�9�u�z�z�!����#�#��9�9�u�z�z�!��#�#����r1c��	t|d��}|j�}|j�}|j|�Sr�)r�rr�)r6r�r7rZ�os     r/�compare_total_magzDecimal.compare_total_magts;��	��u�d�3���M�M�O���N�N������q�!�!r1c�\�	td|j|j|j�Sra)rCrEr�r�r�s r/rzDecimal.copy_abss$��5���4�9�9�d�i�i��9I�9I�J�Jr1c���	|jr,td|j|j|j�Std|j|j|j�S)Nr(r2)rDrCrEr�r�r�s r/rzDecimal.copy_negate�sJ��4��:�:�#�A�t�y�y�$�)�)�T�=M�=M�N�N�#�A�t�y�y�$�)�)�T�=M�=M�N�Nr1c��	t|d��}t|j|j|j|j
�Sr�)r�rCrDrEr�r�r�s   r/�	copy_signzDecimal.copy_sign�s9��2��u�d�3������T�Y�Y� $�	�	�4�+;�+;�=�	=r1c��	|�
t�}|j|��}|r|S|j�dk(rtS|stS|j�dk(rt|�S|j}|j�}|jdk(rC|tt|jdzdz��kDrtdd|jdz�}�nE|jdk(rK|tt|j�dzdz��kDrtdd|j�dz
�}n�|jdk(r!||krtddd|dz
zzdz|�}n�|jdk(r!||dz
krtdd|dzz|dz
�}n�t|�}|j|j }}|j"dk(r|}d}	t%||||z�\}	}
|	d	d
tt|	��|z
dz
zzzrn|dz
}�=tdt|	�|
�}|j'�}|j)t*�}|j-|�}||_|S)Nrpr�r2r(r�r1r�r^r�r�)rr�r�r�r�rr`r�rDr�r�rarCr6r�r�r�rQ�_dexpr�r�rrr_)r6r7rHr��adjr�r�rr�r�r�r_s            r/r�zDecimal.exp�sE�� ��?� �l�G����w��/����J������#��L���K������"��4�=� �
�L�L���m�m�o���:�:��?�s�S��g�l�l�1�n�a�-?�)@�%A�A�"�1�c�7�<�<��>�:�C�
�Z�Z�1�_��s�3�����0@��0B�A�/E�+F�'G�!G�"�1�c�7�=�=�?�1�+<�=�C�
�Z�Z�1�_���r��"�1�c�C��1��I�o��&;�a�R�@�C�
�Z�Z�1�_���r�!�t��"�1�c�1�Q�3�i�!��A��6�C��$��B��6�6�2�6�6�q�A��w�w�!�|��B��
�E��"�1�a��5��1�
��s��A�b�3�s�5�z�?�1�#4�Q�#6�7�7�8����
��	�#�1�c�%�j�#�6�C��'�'�)���(�(��9���h�h�w���#����
r1c��	y)NTr-r�s r/�is_canonicalzDecimal.is_canonical�s��	�
r1c��	|jSr,)r�r�s r/�	is_finitezDecimal.is_finite�s��	�
�#�#�#�#r1c�"�	|jdk(S)Nr��r�r�s r/r�zDecimal.is_infinite�s��F��y�y�C��r1c� �	|jdvS)Nr�rr�s r/r�zDecimal.is_nan�s��L��y�y�J�&�&r1c�t�	|js|sy|�
t�}|j|j�kS�NF)r�rrfr�rs  r/�	is_normalzDecimal.is_normal�s4��M����4���?� �l�G��|�|�t�}�}��.�.r1c�"�	|jdk(S)NrBrr�s r/r�zDecimal.is_qnan�s��I��y�y�C��r1c�"�	|jdk(S�Nr2)rDr�s r/�	is_signedzDecimal.is_signed�s��F��z�z�Q��r1c�"�	|jdk(S)Nr�rr�s r/r�zDecimal.is_snans��M��y�y�C��r1c�t�	|js|sy|�
t�}|j�|jkSr)r�rr�rfrs  r/�is_subnormalzDecimal.is_subnormals4��G����4���?� �l�G��}�}�����-�-r1c�@�	|jxr|jdk(Sr�r�r�s r/�is_zerozDecimal.is_zeros"��D��#�#�#�8��	�	�S�(8�8r1c���	|jt|j�zdz
}|dk\rtt|dzdz��dz
S|dkr ttd|z
dzdz��dz
St	|�}|j
|j}}|dk(r:t|d|zz
�}t|�}t|�t|�z
||kz
S|ttd|z|z
��zdz
S)Nr2�r�r�r�r(�r�r�rEr�r�r�r��r6rr�r�r�num�dens       r/�
_ln_exp_boundzDecimal._ln_exp_bounds���	��i�i�#�d�i�i�.�(�1�,���!�8��s�3�r�6�2�:��'�!�+�+��"�9��s�B�s�F�B�;��?�+�,�q�0�0�
�d�^���v�v�r�v�v�1���!�8��a��Q�B��h�-�C��a�&�C��s�8�c�#�h�&�#��)�4�4��3�s�2��r�6�A�:��'�'�!�+�+r1c
���	|�
t�}|j|��}|r|S|stS|j�dk(rtS|t
k(rtS|jdk(r|jtd�St|�}|j|j}}|j}||j�z
dz}	t|||�}|ddt!t#t%|���|z
dz
zzzrn|dz
}�@t't|dk�t#t%|��|�}|j)�}|j+t,�}	|j/|�}|	|_|S)	Nrpr2zln of a negative valuer�r�r�r�r()rr��_NegativeInfinityr��	_Infinityr�r�rDr�r
r�r�r�r`r%�_dlogr�r�r�rCr�r�rrr_�
r6r7rHr�r�rr�r�r�r_s
          r/�lnz
Decimal.ln,sm��=��?� �l�G����w��/����J��$�$������"����4�<��L��:�:��?��'�'�(8�(@�B�
B��d�^���v�v�r�v�v�1���L�L���T�'�'�)�)�A�-����!�Q��'�E���"�s�3�s�5�z�?�3�A�5�a�7�8�8�9���a�K�F���s�5��7�|�S��U��_�v�g�F���'�'�)���(�(��9���h�h�w���#����
r1c���	|jt|j�zdz
}|dk\rtt|��dz
S|dkrttd|z
��dz
St	|�}|j
|j}}|dk(r@t|d|zz
�}td|z�}t|�t|�z
||kz
dzStd|z|z
�}t|�|z|dkz
dz
S)	Nr2r�r�r(r���r��231r!r"s       r/r�zDecimal._log10_exp_bound^s���	��i�i�#�d�i�i�.�(�1�,���!�8��s�3�x�=��?�"��"�9��s�2�c�6�{�#�A�%�%�
�d�^���v�v�r�v�v�1���!�8��a��Q�B��h�-�C��c�!�e�*�C��s�8�c�#�h�&�#��)�4�q�8�8��"�q�b�&��(�m���3�x�!�|�s�U�{�+�a�/�/r1c
��	|�
t�}|j|��}|r|S|stS|j�dk(rtS|j
dk(r|j
td�S|jddk(rZ|jdddt|j�dz
zk(r/t|jt|j�zdz
�}n�t|�}|j|j}}|j}||j!�z
dz}	t#|||�}|dd	tt%t'|���|z
dz
zzzrn|d
z
}�@t)t|dk�t%t'|��|�}|j+�}|j-t.�}	|j1|�}|	|_|S)Nrpr2zlog10 of a negative valuer(r1r�r�r�r�r�)rr�r'r�r(rDr�r
rEr�rr�r�r�r�r`r��_dlog10r�r�rCr�r�rrr_r*s
          r/�log10z
Decimal.log10|s���4��?� �l�G����w��/����J��$�$������"����:�:��?��'�'�(8�(C�E�
E��9�9�Q�<�3��4�9�9�Q�R�=�C��T�Y�Y��!�9K�4L�#L��$�)�)�c�$�)�)�n�4�q�8�9�C��$��B��6�6�2�6�6�q�A����A��t�,�,�.�.�q�0�F����1�f�-���A�b�3�s�3�u�:��#7��#9�!�#;�<�<�=���!����#�3�u�Q�w�<��S��Z��6�'�J�C��'�'�)���(�(��9���h�h�w���#����
r1c��	|j|��}|r|S|�
t�}|j�rtS|s|j	t
dd�St
|j��}|j|�S)Nrpzlogb(0)r2)	r�rr�r(r�rrr�rrs   r/�logbzDecimal.logb�s��	����w��/����J��?� �l�G���������'�'��	�1�E�E�
�d�m�m�o�&���x�x�� � r1c�r�	|jdk7s|jdk7ry|jD]}|dvs�yy)Nr(F�01T)rDr�rE)r6�digs  r/�
_islogicalzDecimal._islogical�s>��	��:�:��?�d�i�i�1�n���9�9�C��$����r1c��|jt|�z
}|dkDr	d|z|z}n|dkr||jd}|jt|�z
}|dkDrd|z|z}||fS|dkr||jd}||fS)Nr(r�)r`r�)r6r7�opa�opb�difs     r/�
_fill_logicalzDecimal._fill_logical�s����l�l�S��X�%����7��c�'�C�-�C�
�1�W��w�|�|�m�n�%�C��l�l�S��X�%����7��c�'�C�-�C��C�x���1�W��w�|�|�m�n�%�C��C�x�r1c���	|�
t�}t|d��}|j�r|j�s|jt�S|j||j|j�\}}djt||�D��cgc]%\}}tt|�t|�z���'c}}�}td|jd�xsdd�Scc}}w�NTr�r�r(r��
rr�r7r�r
r<rEr��zipr�r�rCr��r6r�r7r9r:r��br�s        r/�logical_andzDecimal.logical_and�����I��?� �l�G��u�d�3����� ��(8�(8�(:��'�'�(8�9�9��'�'�����E�J�J�G�
��c�����C���E����1�#�c�!�f�S��V�m�,��E�F����6�=�=��#5�#<��a�@�@��F��*C&
c�p�	|�
t�}|jtdd|jzd�|�S)Nr(r1)r�logical_xorrCr`rs  r/�logical_invertzDecimal.logical_invert�s<��$��?� �l�G���� 0��3�w�|�|�3C�A� F� '�)�	)r1c���	|�
t�}t|d��}|j�r|j�s|jt�S|j||j|j�\}}djt||�D��cgc]%\}}tt|�t|�z���'c}}�}td|jd�xsdd�Scc}}wr>r?rAs        r/�
logical_orzDecimal.logical_or
s���H��?� �l�G��u�d�3����� ��(8�(8�(:��'�'�(8�9�9��'�'�����E�J�J�G�
��c�����C���E����1�#�c�!�f�S��V�m�,��E�F����6�=�=��#5�#<��a�@�@��FrEc���	|�
t�}t|d��}|j�r|j�s|jt�S|j||j|j�\}}djt||�D��cgc]%\}}tt|�t|�z���'c}}�}td|jd�xsdd�Scc}}wr>r?rAs        r/rGzDecimal.logical_xor
rDrEc��	t|d��}|�
t�}|js|jrl|j�}|j�}|s|rH|dk(r|dk(r|j	|�S|dk(r|dk(r|j	|�S|j||�S|j
�j|j
��}|dk(r|j|�}|dk(r|}n|}|j	|�Sr��	r�rr�r�rr�rr�r�r�s       r/�max_magzDecimal.max_mag"
s���F��u�d�3���?� �l�G����u�0�0�����B�����B��R���7�r�Q�w��9�9�W�-�-���7�r�Q�w� �:�:�g�.�.��'�'��w�7�7��M�M�O� � ����!1�2����6��"�"�5�)�A���7��C��C��x�x�� � r1c��	t|d��}|�
t�}|js|jrl|j�}|j�}|s|rH|dk(r|dk(r|j	|�S|dk(r|dk(r|j	|�S|j||�S|j
�j|j
��}|dk(r|j|�}|dk(r|}n|}|j	|�Sr�rMr�s       r/�min_magzDecimal.min_mag@
s���F��u�d�3���?� �l�G����u�0�0�����B�����B��R���7�r�Q�w��9�9�W�-�-���7�r�Q�w� �:�:�g�.�.��'�'��w�7�7��M�M�O� � ����!1�2����6��"�"�5�)�A���7��C��C��x�x�� � r1c���	|�
t�}|j|��}|r|S|j�dk(rtS|j�dk(r(t	dd|j
z|j
��S|j�}|jt�|j�|j|�}||k7r|S|jt	dd|j�dz
�|�S)Nrpr�r2r(r^r1)rr�r�r'rCr`rnrrr�r�_ignore_all_flagsrr-r6�r6r7rH�new_selfs    r/�
next_minuszDecimal.next_minus^
s���K��?� �l�G����w��/����J������#�$�$������"�#�A�s�7�<�<�'7�����H�H��,�,�.�����k�*��!�!�#��9�9�W�%���t���O��|�|�,�Q��W�]�]�_�Q�5F�G�#�%�	%r1c���	|�
t�}|j|��}|r|S|j�dk(rtS|j�dk(r(t	dd|j
z|j
��S|j�}|jt�|j�|j|�}||k7r|S|jt	dd|j�dz
�|�S)Nrpr2r�r^r(r1)rr�r�r(rCr`rnrrr�rrRrr+r6rSs    r/�	next_pluszDecimal.next_plusu
s���K��?� �l�G����w��/����J������"��������#�#�A�s�7�<�<�'7�����H�H��,�,�.�����m�,��!�!�#��9�9�W�%���t���O��|�|�,�Q��W�]�]�_�Q�5F�G�#�%�	%r1c���	t|d��}|�
t�}|j||�}|r|S|j|�}|dk(r|j	|�S|dk(r|j|�}n|j
|�}|j�rM|jtd|j�|jt�|jt�|S|j�|jkrk|jt�|jt �|jt�|jt�|s|jt"�|S)NTr�r(r�z Infinite result from next_toward)r�rr�r�rrWrUr�r�rrDrr
r�rfrrr	)r6r�r7rH�
comparisons     r/�next_towardzDecimal.next_toward�
s2��	��u�d�3���?� �l�G����u�g�.����J��Y�Y�u�%�
���?��>�>�%�(�(�����.�.��)�C��/�/�'�*�C��?�?��� � ��!C�!$���
,�
� � ��)�� � ��)��
��\�\�^�g�l�l�
*�� � ��+�� � ��+�� � ��)�� � ��)���$�$�W�-��
r1c�0�	|j�ry|j�ry|j�}|dk(ry|dk(ry|j�r|jryy|�
t�}|j
|�	�r|jry
y|jryy
)Nr�rr2z	+Infinityr�z	-Infinityz-Zeroz+Zerorpz
-Subnormalz
+Subnormalz-Normalz+Normal)r�r�r�rrDrr)r6r7�infs   r/�number_classzDecimal.number_class�
s���
	��<�<�>���<�<�>����� ���!�8���"�9���<�<�>��z�z����?� �l�G����W��-��z�z�#�#��:�:��r1c��	td�S�Nr�rbr�s r/�radixz
Decimal.radix�
s��5��r�{�r1c�n�	|�
t�}t|d��}|j||�}|r|S|jdk7r|j	t
�S|jt|�cxkr|jksn|j	t
�S|j�rt|�St|�}|j}|jt|�z
}|dkDr	d|z|z}n|dkr||d}||d|d|z}t|j|jd�xsd|j�S�NTr�r(r��rr�r�r�r�r
r`r�r�rrEr�rCrDr�)r6r�r7rH�torot�rotdig�topad�rotateds        r/�rotatezDecimal.rotate�
s*��C��?� �l�G��u�d�3�����u�g�.����J��:�:��?��'�'�(8�9�9����
��U��;�w�|�|�;��'�'�(8�9�9������4�=� ��E�
���������s�6�{�*���1�9���Y��'�F�
�Q�Y��U�F�G�_�F����.�6�&�5�>�1����
�
� '���s� 3� :�s�D�I�I�G�	Gr1c�:�	|�
t�}t|d��}|j||�}|r|S|jdk7r|j	t
�Sd|j|jzz}d|j|jzz}|t|�cxkr|ksn|j	t
�S|j�rt|�St|j|j|jt|�z�}|j|�}|S)NTr�r(r�r�)rr�r�r�r�r
rar`r�r�rrCrDrEr)r6r�r7rH�liminf�limsupr�s       r/�scalebzDecimal.scaleb	s���L��?� �l�G��u�d�3�����u�g�.����J��:�:��?��'�'�(8�9�9��w�|�|�g�l�l�2�3���w�|�|�g�l�l�2�3���#�e�*�.��.��'�'�(8�9�9������4�=� ��T�Z�Z����D�I�I��E�
�4J�K��
�F�F�7�O���r1c��	|�
t�}t|d��}|j||�}|r|S|jdk7r|j	t
�S|jt|�cxkr|jksn|j	t
�S|j�rt|�St|�}|j}|jt|�z
}|dkDr	d|z|z}n|dkr||d}|dkr|d|}n|d|zz}||jd}t|j|jd�xsd|j�Srbrc)r6r�r7rHrdrerf�shifteds        r/r8z
Decimal.shift"sF��C��?� �l�G��u�d�3�����u�g�.����J��:�:��?��'�'�(8�9�9����
��U��;�w�|�|�;��'�'�(8�9�9������4�=� ��E�
���������s�6�{�*���1�9���Y��'�F�
�Q�Y��U�F�G�_�F��1�9��V�e�n�G��s�5�y�(�G��w�|�|�m�n�-�G���
�
�$+�N�N�3�$7�$>�3��	�	�K�	Kr1c�2�|jt|�ffSr,)�	__class__r�r�s r/�
__reduce__zDecimal.__reduce__Is������T���-�-r1c�\�t|�tur|S|jt|��Sr,��typerrpr�r�s r/�__copy__zDecimal.__copy__L�&����:�� ��K��~�~�c�$�i�(�(r1c�\�t|�tur|S|jt|��Sr,rs)r6�memos  r/�__deepcopy__zDecimal.__deepcopy__Qrvr1c��	|�
t�}t||��}|jrIt|j|�}t|j
��}|ddk(r|dz
}t|||�S|d�ddg|j|d<|ddk(r.t|j|j|jdz�}|j}|d}|�i|ddvr|j|d	z|�}nL|dd
vr|j||�}n1|ddvr*t|j�|kDr|j||�}|s(|jdkDr|dd
vr|jd|�}|s|d
r|jrd}	n|j}	|jt|j�z}
|ddvr
|s|�d	|z
}n-d	}n*|dd
vr|
}n |ddvr|jdkr|
dkDr|
}nd	}dkrd}d|z|jz}
ne|t|j�kDr+|jd|t|j�z
zz}d}
n"|jd|xsd}|j|d}
|
|z
}t!|	||
||�S)N)�_localeconvrt�%�g�Gr��	precision�eEr2zfF%�gGr(�no_neg_0r
r�r�)r�_parse_format_specifierr��_format_signrDr�r�
_format_alignrgrCrEr�r_r�r&r��_format_number)r6�	specifierr7r{�specrQ�bodyr_r�
adjusted_signrrr�r�r�s               r/�
__format__zDecimal.__format__Xs���	��?� �l�G�&�y�k�J�������
�
�D�1�D��t�}�}��'�D��F�|�s�"����� ��t�T�2�2���<����:�g�&6�&6�7�D��L���<�3��#�D�J�J��	�	�4�9�9�Q�;�G�D��#�#����%�	�� ��F�|�t�#��{�{�9�Q�;��9���f���&��}�}�i�Z��:���f���%�#�d�i�i�.�9�*D��{�{�9�h�7����	�	�A�
�$�v�,�%�*?��=�=��H�-�D���Z�(�T�Z�Z��M� �J�J�M��Y�Y��T�Y�Y��/�
���<�4���I�1��y�=����
�&�\�U�
"�!�H�
�&�\�T�
!��y�y�A�~�*�r�/�%�����a�<��G��X�I�����2�H�
��D�I�I��
&��i�i�#�x��D�I�I��'>�"?�?�G��H��i�i�	��*�1�c�G��y�y���+�H���!���m�W�h��T�J�Jr1)r�N)NNr,)FN)TN)�r:r;r<�	__slots__r��classmethodr�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r	rrrr r#r+�__radd__r-r/r4�__rmul__r;r@rBrHrJrLrNrRrTrVr[r]�	__trunc__�propertyr_rcrerhrFrryr{r~r�r�r�r�r��dictror�r�r�r�r�r�r�r�r�r�r�r&r�r�r��to_integralr�r%rr�r�r�r�r�r�rrrrr�r
rr�r�rr�rr�rrr%r+r�r1r3r7r<rCrHrJrGrNrPrUrWrZr]r`rhrlr8rqruryr�r-r1r/rr�s���6�6�I�T@�l�*��*�X
���@�B4�-'�@%�$�%�$�%�)�$(�4O�0�d+�
2/�h7�!�,!�*�,T�l�H�B�4�6�n�H�9!�v�B8�"#�H7��64�I!�V/�89��7��I�
���������$�
�Z�L�'��-�-�+�+�+�#� ��&�*�*�&�"� �	��<6�|
2�
4�*/�XS4�jv?�pV�p4�@�2;�z
'� 8�D�.�:.�"$�K�a�F(!�T !�D%�2���
4�F�R	"�K�O�=�I�V�$� �'�/� �� �.�9�,�20�d0�<1�f!�<��A�")�A�"A�"!�<!�<%�.%�.,�\(�T�G�B�2$K�N.�)�
)�TKr1rc�r�	tjt�}||_||_||_||_|Sr,)r�r�rrDrEr�r�)rQ�coefficientr��specialr6s     r/rCrC�s9����>�>�'�"�D��D�J��D�I��D�I��D���Kr1c� �eZdZ	d�Zd�Zd�Zy)rvc�.�|j�|_yr,)rrr{)r6r{s  r/�__init__z_ContextManager.__init__�s��&�+�+�-��r1c�b�t�|_t|j�|jSr,)r�
saved_contextrr{r�s r/�	__enter__z_ContextManager.__enter__�s&��'�\����4�#�#�$����r1c�.�t|j�yr,)rr�)r6�t�v�tbs    r/�__exit__z_ContextManager.__exit__�s���4�%�%�&r1N)r:r;r<r�r�r�r-r1r/rvrv�s���
.� �'r1rvc��eZdZ				dSd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
e
ZdTd
�Zd�Zd�Zd�ZdZd�Zd�Zd�ZdUd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d �Z#d!�Z$d"�Z%d#�Z&d$�Z'd%�Z(d&�Z)d'�Z*d(�Z+d)�Z,d*�Z-d+�Z.d,�Z/d-�Z0d.�Z1d/�Z2d0�Z3d1�Z4d2�Z5d3�Z6d4�Z7d5�Z8d6�Z9d7�Z:d8�Z;d9�Z<d:�Z=d;�Z>d<�Z?d=�Z@d>�ZAd?�ZBd@�ZCdA�ZDdB�ZEdC�ZFdTdD�ZGdE�ZHdF�ZIdG�ZJdH�ZKdI�ZLdJ�ZMdK�ZNdL�ZOdM�ZPdN�ZQdO�ZRdP�ZSdQ�ZTdR�ZUeUZVy)VrNc
����	t}
|�|n
j|_|�|n
j|_|�|n
j|_|�|n
j
|_|�|n
j|_|�|n
j|_|	�g|_n|	|_�� 
jj�|_	n8t�t�s!t�fd�t�zD��|_	n�|_	�� tjtd�|_yt�t�s!t�fd�t�zD��|_y�|_y#t$rY��PwxYw)Nc3�<�K�|]}|t|�v�f���y�wr,�r�)�.0rZrjs  �r/�	<genexpr>z#Context.__init__.<locals>.<genexpr>�!�����M�<L�q�q�#�a�5�j�/�2�<L���r(c3�<�K�|]}|t|�v�f���y�wr,r�)r�rZris  �r/r�z#Context.__init__.<locals>.<genexpr>r�r�)r�	NameErrorr`r_rfrargrh�_ignored_flagsrjrrr�r�r��fromkeysri)r6r`r_rfrargrhrirjr��dcs       ``  r/r�zContext.__init__�s"���
	��B�!�,�D�"�'�'��	�$,�$8��b�k�k��
� �,�D�"�'�'��	� �,�D�"�'�'��	�$,�$8��b�k�k��
�#�/�U�R�X�X��
��!�"$�D��"0�D���=�������D�J��E�4�(��M�H�u�<L�M�M�D�J��D�J��=����x��3�D�J��E�4�(��M�H�u�<L�M�M�D�J��D�J��7�	��	�s�E�	E�Ec��t|t�std|z��|dk(r||kDrJtd||||fz��|dk(r||kr.td||||fz��||ks||kDrtd||||fz��tj|||�S)Nz%s must be an integer�-infz%s must be in [%s, %d]. got: %sr\z%s must be in [%d, %s]. got: %sz%s must be in [%d, %d]. got %s)r�r�ryr�r��__setattr__)r6�namer��vmin�vmaxs     r/�_set_integer_checkzContext._set_integer_checks����%��%��3�d�:�;�;��6�>��t�|� �!B�d�D�RV�X]�E^�!^�_�_�
�U�]��t�|� �!B�d�D�RV�X]�E^�!^�_�_��t�|�u�t�|� �!A�T�4�QU�W\�D]�!]�^�^��!�!�$��e�4�4r1c���t|t�std|z��|D]}|tvs�t	d|z��tD]}||vs�t	d|z��t
j
|||�S)Nz%s must be a signal dictz%s is not a valid signal dict)r�r�ryr��KeyErrorr�r�)r6r�r�rs    r/�_set_signal_dictzContext._set_signal_dictsz���!�T�"��6��:�;�;��C��(�?��>��B�C�C���C��!�8��>��B�C�C���!�!�$��a�0�0r1c���|dk(r|j||dd�S|dk(r|j||dd�S|dk(r|j||dd�S|dk(r|j||dd�S|d	k(r|j||dd�S|d
k(r-|tvrtd|z��tj	|||�S|dk(s|d
k(r|j||�S|dk(rtj	|||�St
d|z��)Nr`r2r\rfr�r(rargrhr_z%s: invalid rounding moderirjr�z.'decimal.Context' object has no attribute '%s')r��_rounding_modesryr�r�r��AttributeError)r6r�r�s   r/r�zContext.__setattr__%s&���6�>��*�*�4���5�A�A�
�V�^��*�*�4����B�B�
�V�^��*�*�4���5�A�A�
�Z�
��*�*�4���1�=�=�
�W�_��*�*�4���1�=�=�
�Z�
��O�+� � ;�e� C�D�D��%�%�d�D�%�8�8�
�W�_�����(�(��u�5�5�
�%�
%��%�%�d�D�%�8�8� �@�4�G�I�
Ir1c��td|z��)Nz%s cannot be deleted)r�)r6r�s  r/�__delattr__zContext.__delattr__>s���3�d�:�;�;r1c	�z�|jj�D��cgc]
\}}|s�	|��}}}|jj�D��cgc]
\}}|s�	|��}}}|j|j|j
|j|j|j|j||ffScc}}wcc}}wr,)
rirwrjrpr`r_rfrargrh)r6�sigr�rirjs     r/rqzContext.__reduce__Bs���#'�:�:�#3�#3�#5�;�#5���a���#5��;�#'�:�:�#3�#3�#5�;�#5���a���#5��;�������D�M�M�4�9�9�d�i�i�����
�
�E�5�:�;�	;��<��;s�
B1�B1�
B7�B7c��	g}|jdt|�z�|jj�D��cgc]\}}|s�	|j��}}}|jddj|�zdz�|jj�D��cgc]\}}|s�	|j��}}}|jddj|�zdz�dj|�dzScc}}wcc}}w)NzrContext(prec=%(prec)d, rounding=%(rounding)s, Emin=%(Emin)d, Emax=%(Emax)d, capitals=%(capitals)d, clamp=%(clamp)dzflags=[�, �]ztraps=[�))r��varsrirwr:r�rj)r6rZr�r��namesr�s      r/r	zContext.__repr__Is���'���	���#���:��	�)-�
�
�(8�(8�(:�@�(:���1�a����(:��@�	����T�Y�Y�u�-�-��3�4�(,�
�
�(8�(8�(:�@�(:���1�a����(:��@�	����T�Y�Y�u�-�-��3�4��y�y��|�c�!�!��	A��@s�
C3�	C3�
C9�(C9c�F�	|jD]}d|j|<�yra)ri�r6�flags  r/rszContext.clear_flagsV�!��%��J�J�D� �D�J�J�t��r1c�F�	|jD]}d|j|<�yra)rjr�s  r/�clear_trapszContext.clear_traps[r�r1c���	t|j|j|j|j|j
|j|j|j|j�	}|Sr,)
rr`r_rfrargrhrirjr��r6�ncs  r/r�zContext._shallow_copy`sP��/�
�T�Y�Y��
�
�t�y�y�$�)�)��]�]�D�J�J��
�
�D�J�J��(�(�*���	r1c��	t|j|j|j|j|j
|j|jj�|jj�|j�	}|Sr,)rr`r_rfrargrhrirrrjr�r�s  r/rrzContext.copygs_��,�
�T�Y�Y��
�
�t�y�y�$�)�)��]�]�D�J�J��Z�Z�_�_�&��
�
���(9��(�(�*���	r1c��	tj||�}||jvr|�j|g|���Sd|j|<|j
|s|�j|g|���S||��r)�_condition_maprmr�r8rirj)r6�	condition�explanationr.�errors     r/r�zContext._raise_errorps���	��"�"�9�i�8���D�'�'�'�!�5�7�>�>�$�.��.�.���
�
�5���z�z�%� �%�9�;�%�%�d�2�T�2�2��K� � r1c�*�	|jt�Sr,)�
_ignore_flagsr�r�s r/rRzContext._ignore_all_flags�s��2�!�t�!�!�8�,�,r1c�T�	|jt|�z|_t|�Sr,)r�r�)r6ris  r/r�zContext._ignore_flags�s(��2� $�2�2�T�%�[�@����E�{�r1c��	|rt|dttf�r|d}|D]}|jj	|��yra)r�r�r�r��remove)r6rir�s   r/�
_regard_flagszContext._regard_flags�s@��9��Z��a��5��,�7��!�H�E��D����&�&�t�,�r1c�N�	t|j|jz
dz�Sr)r�rfr`r�s r/r6z
Context.Etiny�s"��/��4�9�9�t�y�y�(�1�,�-�-r1c�N�	t|j|jz
dz�Sr)r�rar`r�s r/rnzContext.Etop�s"��:��4�9�9�t�y�y�(�1�,�-�-r1c�.�	|j}||_|Sr,)r_)r6rtr_s   r/r�zContext._set_rounding�s��
	��=�=����
��r1c�d�	t|t�r-||j�k7sd|vr|jtd�St||��}|j
�rEt|j�|j|jz
kDr|jtd�S|j|�S)Nr�zAtrailing or leading whitespace and underscores are not permitted.rpzdiagnostic info too long in NaN)r�r�r�r�rrr�r�rEr`rhr)r6r#r�s   r/�create_decimalzContext.create_decimal�s���	&�
�c�3��S�C�I�I�K�%7�3�#�:��$�$�%5�&F�G�
G�
�C��&���8�8�:�#�a�f�f�+��	�	�D�J�J�(>�>��$�$�%5�%F�H�
H��v�v�d�|�r1c�P�	tj|�}|j|�Sr,)rr�r)r6r�r�s   r/�create_decimal_from_floatz!Context.create_decimal_from_float�s'��	�
���q�!���v�v�d�|�r1c�B�	t|d��}|j|��Sr�)r�r#�r6r�s  r/r�zContext.abs�s&��	�"
�1�d�+���y�y��y�&�&r1c�t�	t|d��}|j||��}|turtd|z��|S�NTr�rp�Unable to convert %s to Decimal)r�r+r�ry�r6r�rBr?s    r/�addzContext.add�sE��	�
�1�d�+��
�I�I�a��I�&������=��A�B�B��Hr1c�6�t|j|��Sr,)r�rr�s  r/�_applyzContext._applys���1�6�6�$�<� � r1c�Z�	t|t�std��|j�S)Nz,canonical requires a Decimal as an argument.)r�rryr�r�s  r/r�zContext.canonicals+��	��!�W�%��J�K�K��{�{�}�r1c�D�	t|d��}|j||��Sr�)r�r��r6r�rBs   r/r�zContext.compares)��	�@
�1�d�+���y�y��D�y�)�)r1c�D�	t|d��}|j||��Sr�)r�r�r�s   r/r�zContext.compare_signal7s+��	�>
�1�d�+������4��0�0r1c�@�	t|d��}|j|�Sr�)r�r�r�s   r/r�zContext.compare_totalZs$��	�2
�1�d�+�����q�!�!r1c�@�	t|d��}|j|�Sr�)r�rr�s   r/rzContext.compare_total_magws&��	�
�1�d�+���"�"�1�%�%r1c�>�	t|d��}|j�Sr�)r�rr�s  r/rzContext.copy_abss!��	�
�1�d�+���z�z�|�r1c�4�	t|d��}t|�Sr�)r�rr�s  r/�copy_decimalzContext.copy_decimal�s��	�
�1�d�+���q�z�r1c�>�	t|d��}|j�Sr�)r�rr�s  r/rzContext.copy_negate�s!��	�
�1�d�+���}�}��r1c�@�	t|d��}|j|�Sr�)r�rr�s   r/rzContext.copy_sign�s#��	�(
�1�d�+���{�{�1�~�r1c�t�	t|d��}|j||��}|turtd|z��|Sr�)r�r;r�ryr�s    r/�dividezContext.divide�sE��	�:
�1�d�+��
�M�M�!�T�M�*������=��A�B�B��Hr1c�t�	t|d��}|j||��}|turtd|z��|Sr�)r�rTr�ryr�s    r/�
divide_intzContext.divide_int�sE��	�
�1�d�+��
�N�N�1�d�N�+������=��A�B�B��Hr1c�t�	t|d��}|j||��}|turtd|z��|Sr�)r�rHr�ryr�s    r/r7zContext.divmod�sE��	�
�1�d�+��
�L�L��D�L�)������=��A�B�B��Hr1c�B�	t|d��}|j|��Sr�)r�r�r�s  r/r�zContext.exps&��	�(�!�T�*���u�u�T�u�"�"r1c�F�	t|d��}|j|||��Sr�)r�r�)r6r�rBr�s    r/r�zContext.fma's*��	�&
�1�d�+���u�u�Q��4�u�(�(r1c�Z�	t|t�std��|j�S)Nz/is_canonical requires a Decimal as an argument.)r�rryr
r�s  r/r
zContext.is_canonical>s,��	��!�W�%��M�N�N��~�~��r1c�>�	t|d��}|j�Sr�)r�rr�s  r/rzContext.is_finiteKs!��	�$
�1�d�+���{�{�}�r1c�>�	t|d��}|j�Sr�)r�r�r�s  r/r�zContext.is_infiniteas!��
	�
�1�d�+���}�}��r1c�>�	t|d��}|j�Sr�)r�r�r�s  r/r�zContext.is_nanps!��	�
�1�d�+���x�x�z�r1c�B�	t|d��}|j|��Sr�)r�rr�s  r/rzContext.is_normal�s&��	�&
�1�d�+���{�{�4�{�(�(r1c�>�	t|d��}|j�Sr�)r�r�r�s  r/r�zContext.is_qnan�s!��
	�
�1�d�+���y�y�{�r1c�>�	t|d��}|j�Sr�)r�rr�s  r/rzContext.is_signed�s!��	�
�1�d�+���{�{�}�r1c�>�	t|d��}|j�Sr�)r�r�r�s  r/r�zContext.is_snan�s!��	�
�1�d�+���y�y�{�r1c�B�	t|d��}|j|��Sr�)r�rr�s  r/rzContext.is_subnormal�s&��	�$
�1�d�+���~�~�d�~�+�+r1c�>�	t|d��}|j�Sr�)r�rr�s  r/rzContext.is_zero�s!��	�
�1�d�+���y�y�{�r1c�B�	t|d��}|j|��Sr�)r�r+r�s  r/r+z
Context.ln�s&��	�$
�1�d�+���t�t�D�t�!�!r1c�B�	t|d��}|j|��Sr�)r�r1r�s  r/r1z
Context.log10s&��	�0
�1�d�+���w�w�t�w�$�$r1c�B�	t|d��}|j|��Sr�)r�r3r�s  r/r3zContext.logb s&��	�,
�1�d�+���v�v�d�v�#�#r1c�D�	t|d��}|j||��Sr�)r�rCr�s   r/rCzContext.logical_and:�(��	�.
�1�d�+���}�}�Q��}�-�-r1c�B�	t|d��}|j|��Sr�)r�rHr�s  r/rHzContext.logical_invertUs)��	�
�1�d�+�������-�-r1c�D�	t|d��}|j||��Sr�)r�rJr�s   r/rJzContext.logical_orhs(��	�.
�1�d�+���|�|�A�t�|�,�,r1c�D�	t|d��}|j||��Sr�)r�rGr�s   r/rGzContext.logical_xor�rr1c�D�	t|d��}|j||��Sr�)r�r%r�s   r/r%zContext.max��(��	�.
�1�d�+���u�u�Q��u�%�%r1c�D�	t|d��}|j||��Sr�)r�rNr�s   r/rNzContext.max_mag��(��	�
�1�d�+���y�y��D�y�)�)r1c�D�	t|d��}|j||��Sr�)r�rr�s   r/rzContext.min�rr1c�D�	t|d��}|j||��Sr�)r�rPr�s   r/rPzContext.min_mag�rr1c�B�	t|d��}|j|��Sr�)r�rr�s  r/�minusz
Context.minus��&��	�
�1�d�+���y�y��y�&�&r1c�t�	t|d��}|j||��}|turtd|z��|Sr�)r�r4r�ryr�s    r/�multiplyzContext.multiplysE��	�0
�1�d�+��
�I�I�a��I�&������=��A�B�B��Hr1c�B�	t|d��}|j|��Sr�)r�rUr�s  r/rUzContext.next_minus's&��	� 
�1�d�+���|�|�D�|�)�)r1c�B�	t|d��}|j|��Sr�)r�rWr�s  r/rWzContext.next_plus;s&��	� 
�1�d�+���{�{�4�{�(�(r1c�D�	t|d��}|j||��Sr�)r�rZr�s   r/rZzContext.next_towardOs(��	�>
�1�d�+���}�}�Q��}�-�-r1c�B�	t|d��}|j|��Sr�)r�r�r�s  r/r�zContext.normalizers&��	�(
�1�d�+���{�{�4�{�(�(r1c�B�	t|d��}|j|��Sr�)r�r]r�s  r/r]zContext.number_class�s'��-	�\
�1�d�+���~�~�d�~�+�+r1c�B�	t|d��}|j|��Sr�)r�r r�s  r/�pluszContext.plus�rr1c�v�	t|d��}|j|||��}|turtd|z��|Sr�)r�r�r�ry)r6r�rBr�r?s     r/�powerz
Context.power�sI��G	�P
�1�d�+��
�I�I�a���I�.������=��A�B�B��Hr1c�D�	t|d��}|j||��Sr�)r�r�r�s   r/r�zContext.quantizes)��5	�l
�1�d�+���z�z�!�T�z�*�*r1c��	td�Sr_rbr�s r/r`z
Context.radixWs��	�
�r�{�r1c�t�	t|d��}|j||��}|turtd|z��|Sr�)r�rLr�ryr�s    r/r9zContext.remainder_sE��	�<
�1�d�+��
�I�I�a��I�&������=��A�B�B��Hr1c�D�	t|d��}|j||��Sr�)r�rRr�s   r/rRzContext.remainder_near�s+��	�<
�1�d�+������4��0�0r1c�D�	t|d��}|j||��Sr�)r�rhr�s   r/rhzContext.rotate�s(��	�2
�1�d�+���x�x��4�x�(�(r1c�@�	t|d��}|j|�Sr�)r�r�r�s   r/r�zContext.same_quantum�s$��	�(
�1�d�+���~�~�a� � r1c�D�	t|d��}|j||��Sr�)r�rlr�s   r/rlzContext.scaleb�s(��	�
�1�d�+���x�x��4�x�(�(r1c�D�	t|d��}|j||��Sr�)r�r8r�s   r/r8z
Context.shift�s(��	�4
�1�d�+���w�w�q�$�w�'�'r1c�B�	t|d��}|j|��Sr�)r�r�r�s  r/r�zContext.sqrt
s&��	�8
�1�d�+���v�v�d�v�#�#r1c�t�	t|d��}|j||��}|turtd|z��|Sr�)r�r-r�ryr�s    r/�subtractzContext.subtract-sE��	�
�1�d�+��
�I�I�a��I�&������=��A�B�B��Hr1c�B�	t|d��}|j|��Sr�)r�rr�s  r/rzContext.to_eng_stringDs&��	�0
�1�d�+�����t��,�,r1c�B�	t|d��}|j|��Sr�)r�rr�s  r/�
to_sci_stringzContext.to_sci_string`s&��	�
�1�d�+���y�y��y�&�&r1c�B�	t|d��}|j|��Sr�)r�r�r�s  r/r�zContext.to_integral_exacths)��	�4
�1�d�+���"�"�4�"�0�0r1c�B�	t|d��}|j|��Sr�)r�r�r�s  r/r�zContext.to_integral_value�s)��	�2
�1�d�+���"�"�4�"�0�0r1)	NNNNNNNNNr,)r�)Wr:r;r<r�r�r�r�r�rqr	rsr�r�rrrur�rRr�r�r�r6rnr�r�r�r�r�r�r�r�r�r�rrr�rrr�r�r7r�r�r
rr�r�rr�rr�rrr+r1r3rCrHrJrGr%rNrrPrrrUrWrZr�r]r r"r�r`r9rRrhr�rlr8r�r-rr0r�r�r�r-r1r/rr�s����$BF�DH�&*�"�H5�	1�I�2<�;�"�!�
!�
���H�!�,-��-��H�.�.��&�"�$'�*�*!��"*�H!1�F"�:&�����0#�J�.�*#�0)�. ��,
�� )�.
��"� ,�,�""�,%�8$�4.�6.�&-�6.�6&�6*�"&�6*�"'�"�@*�()�(!.�F)�00,�d'�"N�`8+�t�$�L 1�D)�:!�0)�&(�<$�@�.-�8'�1�<1�<$�Kr1rc��eZdZdZdd�Zd�Zy)r��rQr�r�Nc�
�|�d|_d|_d|_yt|t�r=|j
|_t|j�|_|j|_y|d|_|d|_|d|_y)Nr(r2r�)rQr�r�r�rrDrEr�)r6r�s  r/r�z_WorkRep.__init__�sn���=��D�I��D�H��D�H�
��w�
'����D�I��5�:�:��D�H��z�z�D�H��a��D�I��Q�x�D�H��Q�x�D�Hr1c�V�d|j�d|j�d|j�d�S)N�(r�r�r4r�s r/r	z_WorkRep.__repr__�s��!%���D�H�H�d�h�h�?�?r1r,)r:r;r<r�r�r	r-r1r/r�r��s��$�I�

 �@r1r�c���	|j|jkr|}|}n|}|}tt|j��}tt|j��}|jt	d||z
dz
�z}||jzdz
|krd|_||_|xjd|j|jz
zzc_|j|_||fS)Nr�r�r2r�)r�r�r�r�r)r)r*r`�tmpr��tmp_len�	other_lenr�s        r/r'r'�s�����w�w��������������#�c�g�g�,��G��C��	�	�N�#�I�

�'�'�C��G�d�N�Q�.�/�
/�C��5�9�9��q� �3�&���	���	��G�G�r�c�g�g��	�	�)�*�*�G��i�i�C�G���8�Or1c��	|dk(ry|dk\r|d|zzStt|��}t|�t|jd��z
}||krdS|d|zzS)Nr(r�r�)r�r�r��rstrip)rBr�str_n�val_ns    r/r�r��sp��	�	�A�v��	
�a���2�q�5�y���C��F����E�
�S����c�!2�3�3����r�z�t�2�q�B���F�{�2r1c�h�	|dks|dkrtd��d}||k7r||||zz
dz	}}||k7r�|S)Nr(z3Both arguments to _sqrt_nearest should be positive.r2)r�)rBr�rBs   r/�
_sqrt_nearestrA�sS���	�A�v��a���N�O�O��A�
�q�&��!�Q�B��E�'�1�*�1���q�&��Hr1c�F�	d|z||z	}}|d||dz
zz|dzz|kDzS)Nr2r�r-)r�r8rBr>s    r/�_rshift_nearestrCs?���
��:�q�E�z�q�A���1��!��9�
��1��%��)�*�*r1c�D�	t||�\}}|d|z|dzz|kDzS)Nr�r2)r7)r�rBr>r?s    r/�_div_nearestrEs3����!�Q�<�D�A�q���!��q��s��a�� � r1c�D�	||z
}d}||krt|�||z
z|k\s||kDr|t|�||z
z	|k\rht||zdz|t||t||�zz|�z�}|dz
}||krt|�||z
z|k\r�N||kDrt|�||z
z	|k\r�ht	dtt
|��zd|zz�}t||�}t||�}t|dz
dd�D]}t||�t||z|�z
}� t||z|�S)Nr(r2���r�r�)r�rErArCr�r�r�r�)	r��M�Lr��R�T�yshift�wr�s	         r/�_ilogrNsA���:	
�!��A�	�A���6�c�!�f��!��m�q�(��q�5�S��V�q��s�]�a�'��!�A�#�!���]�1�a���1�0E�.E�+F��J�J�
L��	�Q���	
��6�c�!�f��!��m�q�(��q�5�S��V�q��s�]�a�'�

�S��S��V��_�q��s�
#�	$�$�A�
�Q��
"�F��Q���A�
�1�Q�3��2�
����A���f�Q�h��!:�:�����!��Q��r1c�L�	|dz
}tt|��}||z||zdk\z
}|dkDrWd|z}||z|z
}|dk\r	|d|zz}nt|d|z�}t||�}t	|�}t||z|�}||z}	nd}t|d|z�}	t|	|zd�S�Nr�r2r(r�r�)r�r�rErN�
_log10_digits)
r�rr�r�r�rHr��log_d�log_10�log_tenpowers
          r/r0r0Ds���:���F�A�	�C��F��A�	�!��q��s�a�x��A��1�u���E��
�a�C��E����6�
��Q��J�A��Q��Q�B��'�A��a�����q�!���U�1�W�f�-����s����#�A�r�A�2�v�.����U�*�C�0�0r1c��	|dz
}tt|��}||z||zdk\z
}|dkDr6||z|z
}|dk\r	|d|zz}nt|d|z�}t|d|z�}nd}|rJttt	|���dz
}||zdk\rt|t||z�zd|z�}nd}nd}t||zd�SrP)r�r�rErNr�rQ)	r�rr�r�r�r�rRr��	f_log_tens	         r/r)r)fs���:���F�A�
	�C��F��A�	�!��q��s�a�x��A�	�1�u�
�a�C��E����6�
��Q��J�A��Q��Q�B��'�A��a��Q������	��C��A��K� ��"���u�9��>�%�Q�}�Q�u�W�'=�%=�r�5�y�I�I��I��	��	�E�)�3�/�/r1c��eZdZ	d�Zd�Zy)�
_Log10Memoizec��d|_y)N�/23025850929940456840179914546843642076011014886)r�r�s r/r�z_Log10Memoize.__init__�s	��G��r1c�B�	|dkrtd��|t|j�k\r\d}	d||zdzz}tt	td|z|�d��}||dd|zk7rn|dz
}�@|j
d�dd|_t|jd|d	z�S)
Nr(zp should be nonnegativer�r�r�r�r�r�r2)r�r�r�r�rErNr=r�)r6r�r�rHr�s     r/�	getdigitsz_Log10Memoize.getdigits�s���	�
�q�5��6�7�7���D�K�K� � ��E����5����O���\�%��1��a�.�#�>�?���5�&�'�?�c�%�i�/����
��
�!�-�-��,�S�b�1�D�K��4�;�;�t��!��$�%�%r1N)r:r;r<r�r\r-r1r/rXrX�s��C�H�&r1rXc�R�	t||z|z�}tdtt|��zd|zz�}t	||�}||z}t|dz
dd�D]}t	|||zz||z�}�t|dz
dd�D]}||dzz}t	|||zz|�}�||zS)NrGr�r2r(r�r�)r�r�r�r�rEr�)	r�rHrIrJrKr��Mshiftr�r�s	         r/�_iexpr_�s���!�(	��1��q�y��A�

�S��S��V��_�q��s�
#�	$�$�A��Q���A�
��T�F�
�1�Q�3��2�
����F�Q�J���!��4����1�Q�3��B�
���Q�q�S�����A�f�H��v�.�� �
�Q�3�Jr1c	�(�	|dz
}td|tt|��zdz
�}||z}||z}|dk\r	|d|zz}n	|d|zz}t|t	|��\}}t|d|z�}tt
|d|z�d�||z
dzfS)Nr�r(r2r�i�r�)r%r�r�r7rQrEr_)	r�rr�r�r>r8�cshift�quotr�s	         r/r
r
�s���4���F�A�
��1�s�3�q�6�{�?�Q�&�'�E�	�E�	�A�
�a�C�E���z��2�u�9����B���J����v�}�Q�/�0�I�D�#��s�B��I�
&�C���c�2�q�5�)�4�0�$��(�Q�,�>�>r1c��	ttt|���|z}t||||zdz�}||z
}|dk\r||zd|zz}nt	||zd|z�}|dk(rCtt|��|zdk\|dkDk(rd|dz
zdzd|z
}
}	|	|
fSd|zdz
|}
}	|	|
fSt||dz|dz�\}	}
t	|	d�}	|
dz
}
|	|
fS)Nr2r(r�)r�r�r�r)rEr
)r�r�r�r�r�rB�lxcr8�pcr�r�s           r/r�r�s���	�C��B��L��B��A���B��!��A��
�C�
�q�D�E���z�
��V�B��I�
��
�#�b�&�"�u�f�*�
-��	�Q�w���R��\�B�
�!�
#��a��0��a��c��1��a��c�3�E��#�:��
�Q��q��1�"�3�E��#�:��	�2��1��v�q��s�+�
��s��U�B�'���q����#�:�r1r��F�5�(�r �r�r�)	r1�2�3�4�5�6�7�8r^c�h�	|dkrtd��t|�}dt|�z||dz
S)Nr(z0The argument to _log10_lb should be nonnegative.r�)r�r�r�)r��
correction�str_cs   r/r�r�*s@��K��A�v��K�L�L���F�E��s�5�z�>�J�u�Q�x�0�0�0r1c���	t|t�r|St|t�rt|�S|r%t|t�rtj	|�S|rtd|z��tS)Nr�)r�rr�r�r�ryr�)r�r��allow_floats   r/r�r�5sc����%��!����%����u�~���z�%��/��!�!�%�(�(���9�E�A�B�B��r1c�z�	t|t�r||fSt|tj�rm|jsJt|jtt|j�|jz�|j�}|t|j�fS|r5t|tj�r|jdk(r|j}t|t �rMt#�}|rd|j$t&<n|j)t&d�|tj+|�fSt,t,fS)Nr(r2r�)r�r�_numbers�Rationalr�rCrDr�r�rE�denominatorr��	numerator�Complexrcr_r�rrirr�r�r�)r6r�r�r7s    r/r�r�Hs�����%��!��U�{���%��*�*�+����#�D�J�J�$'��D�I�I���9J�9J�(J�$K�$(�I�I�/�D��W�U�_�_�-�-�-�
�z�%��)9�)9�:�u�z�z�Q���
�
���%����,���,-�G�M�M�.�)�� � ��M�
O��W�'�'��.�.�.��>�)�)r1r�i?Bi���)r`r_rjrirarfrgrhr�)r`r_rjria�        # A numeric string consists of:
#    \s*
    (?P<sign>[-+])?              # an optional sign, followed by either...
    (
        (?=\d|\.\d)              # ...a number (with at least one digit)
        (?P<int>\d*)             # having a (possibly empty) integer part
        (\.(?P<frac>\d*))?       # followed by an optional fractional part
        (E(?P<exp>[-+]?\d+))?    # followed by an optional exponent, or...
    |
        Inf(inity)?              # ...an infinity, or...
    |
        (?P<signal>s)?           # ...an (optionally signaling)
        NaN                      # NaN
        (?P<diag>\d*)            # with (possibly empty) diagnostic info.
    )
#    \s*
    \Z
z0*$z50*$z�\A
(?:
   (?P<fill>.)?
   (?P<align>[<>=^])
)?
(?P<sign>[-+ ])?
(?P<no_neg_0>z)?
(?P<alt>\#)?
(?P<zeropad>0)?
(?P<minimumwidth>(?!0)\d+)?
(?P<thousands_sep>,)?
(?:\.(?P<precision>0|(?!0)\d+))?
(?P<type>[eEfFgGn%])?
\Z
c�p�	tj|�}|�td|z��|j�}|d}|d}|ddu|d<|dr |�td|z��|�td|z��|xsd|d<|xsd|d<|d	�d
|d	<t	|dxsd�|d<|d
�t	|d
�|d
<|d
dk(r|d�|ddvrd|d
<|ddk(rHd|d<|�tj�}|d�td|z��|d|d<|d|d<|d|d<|S|d�d|d<ddg|d<d|d<|S)NzInvalid format specifier: �fill�align�zeropadz7Fill character conflicts with '0' in format specifier: z2Alignment conflicts with '0' in format specifier: � �>rQr��minimumwidthr�rr(rt�gGnr2rBr}�
thousands_sepzJExplicit thousands separator conflicts with 'n' type in format specifier: �grouping�
decimal_pointr�r�r)�_parse_format_specifier_regex�matchr��	groupdictr��_locale�
localeconv)�format_specr{r��format_dictr~rs      r/r�r��s���$	&�+�+�K�8�A��y��5��C�D�D��+�+�-�K��v��D��� �E�)�)�4�D�@�K�	���9�����6�8C�D�E�
E����2�4?�@�A�
A��+�#�K���!�<�C�K����6��"�!��F��#&�k�.�&A�&H�S�"I�K����;��+�#&�{�;�'?�#@��K� ��;��1�$��v��&�+�f�*=��*F�'(�K��$��6��c�!�!��F����!�,�,�.�K���'�3��>�@K�L�M�
M�'2�?�'C��O�$�"-�j�"9��J��'2�?�'C��O�$�����'�/�+-�K��(�#$�a�&��J��'*��O�$��r1c��	|d}|d}||t|�z
t|�z
z}|d}|dk(r
||z|z}|S|dk(r
||z|z}|S|dk(r
||z|z}|S|dk(r!t|�dz}|d||z|z||dz}|Std	��)
Nr�r~r�<r��=�^r�zUnrecognised alignment field)r�r�)	rQr�r�r�r~�paddingrr��halfs	         r/r�r�&s������'�L���<�D��L�3�t�9�,�s�4�y�8�9�G���M�E���|����w�&���M�
�#���4��$�&���M�
�#�����$�&���M�

�#���7�|�Q�����$��$�&��-�����>���M��7�8�8r1c��	ddlm}m}|sgS|ddk(r#t|�dk\r||dd||d��S|dtj
k(r|ddSt
d��)Nr()�chain�repeatr�r�r�z unrecognised format for grouping)�	itertoolsr�r�r�r��CHAR_MAXr�)r�r�r�s   r/�_group_lengthsr�Asq���(���	�	�"���	�s�8�}��1��X�c�r�]�F�8�B�<�$8�9�9�	�"���)�)�	)����}���;�<�<r1c���	|d}|d}g}t|�D]{}|dkrtd��ttt	|�|d�|�}|jd|t	|�z
z||dz�|d|}||z}|s|dkrnM|t	|�z}�}tt	|�|d�}|jd|t	|�z
z||dz�|j
t|��S)Nr�r�r(zgroup length should be positiver2r�)r�r�rr%r�r�r��reversed)r�r��	min_width�sepr��groupsr�s       r/�_insert_thousands_sepr�Xs��� ��
�C��J��H�
�F�
�H�
%����6��>�?�?���C��K��A�.��2���
�
�c�1�s�6�{�?�+�f�a�R�S�k�9�:���!�����Q��	��)�q�.���S��X��	�&�
��F��Y��*���
�
�c�1�s�6�{�?�+�f�a�R�S�k�9�:��8�8�H�V�$�%�%r1c�$�	|ry|ddvr|dSy)Nr�rQz +r�r-)�is_negativer�s  r/r�r�}s$��#���	
�f���	��F�|��r1c�4�	t||�}|s|dr|d|z}|dk7s|ddvr"ddddd�|d}|d	j||�z
}|dd
k(r|d
z
}|dr|dt|�z
t|�z
}nd}t|||�}t	|||z|�S)
N�altr�r(rtr�rr)rrr~r}z{0}{1:+}r|r�r�)r��formatr�r�r�)r�r�r�r�r�rQ�echarr�s        r/r�r��s����"��T�*�D��4��;���(�8�3��
�a�x�4��<�4�'���#�C�8��f��F���J�%�%�e�S�1�1���F�|�s���C����I����(�3�x�=�8�3�t�9�D�	��	�#�G�T�9�=�G���w�x�/��6�6r1�Infz-Infrr�r�r,)F)r()r�)FF)r2){�__all__r:�	__xname__�__version__�__libmpdec_version__�mathr��numbersrx�sys�collectionsr)�_namedtupler�ImportErrorrrrrrrrrr%r&�maxsizer!r"r#r$�ArithmeticErrorrr	r
r�ZeroDivisionErrorrrrrrr
rrrryrr�r�r��contextvars�
ContextVarrl�	frozensetrxrrr r�rrC�Number�registerrvrr�r'r�r�r�r�rArCrErNr0r)rXr\rQr_r
r�r�r�r�rrr�re�compile�VERBOSE�
IGNORECASEr�r�rwr��DOTALLr��localer�r�r�r�r�r�r�r(r'rGr�r�r�rO�	hash_info�modulusr�r\r�rX�_PyHASH_NANr�r�r-r1r/�<module>r�s��� '�!��F
�	���������
�&�5��~�/E�i�X�L�
�
��
�#���
�����#��
�
������;�;�'��!�H�!�H�"�H��H��H��H����
�#�	�
��
�.
��
��'��:�'��%�%�'8�%� 	�)�	�	�(�*;�	�
��
��%��
��
�	� �	�#:�w��#:�L
���)�
�
�%�y�
� 
�^�W�h���'��N�D��#�#3�$�%5�#�$4� �!1�3���}�o�}���/�:�G���-�{�-�-�.?�@���O����&��+�hB4K�f�B4K�Hh�&	������!�

'�f�
'�O$�f�O$�b6@�v�@�4�<

����3�*

�+�!�. �` 1�D*0�X!&�F�!&�F��)�)�
�#�J"?�H(�V�r���"�
�b�r��+�1��&"*�T�
�/��x�)9�:��
�
������
���x�)9�7�I�N�����
������*
�
�"�*�*��"�Z�Z�"�-�-��#!�""'��#�&�R�Z�Z��
�
$�
$�
��b�j�j�� �&�&��!+��
�
�,��Z�Z��	�	��!�� �
	��N�`�6=�.#&�J�#7�R
�E�N�	��F�O���u�~����
���q�z���r�{���/�0���-�-�'�'���m�m�����m�m�����B��!�+�_�=�
���CD�&�%�L�&��b|�	��	�s#�M%�M4�%M1�0M1�4M<�;M<

?>