Your IP : 18.191.68.112


Current Path : /opt/alt/python39/lib64/python3.9/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/__pycache__/_pydecimal.cpython-39.opt-2.pyc

a

R�f:}�
@slgd�ZeZdZdZdZddlZddlZddl	Z	zddl
mZedd�Z
Wneydd	d
�Z
Yn0dZdZd
ZdZdZdZdZdZdZdZe	jdkr�dZdZdZndZdZdZeedZGdd�de�ZGdd�de�Z Gdd�de�Z!Gd d!�d!e!�Z"Gd"d#�d#ee#�Z$Gd$d%�d%e!�Z%Gd&d'�d'e!e#�Z&Gd(d)�d)e�Z'Gd*d+�d+e!�Z(Gd,d-�d-e�Z)Gd.d/�d/e�Z*Gd0d1�d1e'e)�Z+Gd2d3�d3e'e)e*�Z,Gd4d5�d5ee-�Z.e e$e'e+e)e,e!e*e.g	Z/e"e!e%e!e&e!e(e!iZ0eeeeeeeefZ1ddl2Z2e2�3d6�Z4d7d8�Z5d9d:�Z6[2d�d;d<�Z7Gd=d>�d>e8�Z9d�d@dA�Z:ej;�<e9�GdBdC�dCe8�Z=GdDdE�dEe8�Z>GdFdG�dGe8�Z?d�dHdI�Z@eAjBZCdJdK�ZDdLdM�ZEdNdO�ZFdPdQ�ZGd�dSdT�ZHdUdV�ZIdWdX�ZJGdYdZ�dZe8�ZKeK�jLZMd�d[d\�ZNd]d^�ZOd_d`�ZPdadbdcdddedfdgdhdidj�	fdkdl�ZQd�dmdn�ZRd�dodp�ZSe>dqee$e+e!ggdrdsdddt�ZTe>duee$e+e!e e,ggdv�ZUe>dueggdv�ZVddlWZWeW�XdweWjYeWjZB�j[Z\eW�Xdx�j[Z]eW�Xdy�j[Z^eW�XdzeWjYeWj_B�Z`[WzddlaZbWne�y�Yn0d�d{d|�Zcd}d~�Zddd��Zed�d�d��Zfd�d��Zgd�d��Zhe9d��Zie9d��Zje9d��Zke9d�Zle9d�Zme9d��ZneiejfZoe	jpjqZre	jpjsZte	jpjuZvewdherd�er�Zx[	dS)�)%�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 exponentcGs|S�N�)�argsr*r*�//opt/alt/python39/lib64/python3.9/_pydecimal.py�<lambda>��r-rrrrrrrrTl����l��N�Zol������N�Zoi@�Ti����c@seZdZdd�ZdS)rcGsdSr)r*��self�contextr+r*r*r,�handle�szDecimalException.handleN��__name__�
__module__�__qualname__r3r*r*r*r,r�src@seZdZdS)rN�r5r6r7r*r*r*r,r�src@seZdZdd�ZdS)r	cGs,|r(t|dj|djdd�}|�|�StS)Nr'�nT)�_dec_from_triple�_sign�_int�_fix_nan�_NaN)r1r2r+�ansr*r*r,r3�s
zInvalidOperation.handleNr4r*r*r*r,r	�sr	c@seZdZdd�ZdS)rcGstSr)�r>r0r*r*r,r3szConversionSyntax.handleNr4r*r*r*r,rsrc@seZdZdd�ZdS)r
cGst|Sr))�_SignedInfinity�r1r2�signr+r*r*r,r3szDivisionByZero.handleNr4r*r*r*r,r

s
r
c@seZdZdd�ZdS)rcGstSr)r@r0r*r*r,r3"szDivisionImpossible.handleNr4r*r*r*r,rsrc@seZdZdd�ZdS)rcGstSr)r@r0r*r*r,r3-szDivisionUndefined.handleNr4r*r*r*r,r%src@seZdZdS)rNr8r*r*r*r,r0src@seZdZdd�ZdS)rcGstSr)r@r0r*r*r,r3GszInvalidContext.handleNr4r*r*r*r,r<src@seZdZdS)rNr8r*r*r*r,rJsrc@seZdZdS)r
Nr8r*r*r*r,r
Vsr
c@seZdZdd�ZdS)rcGs�|jttttfvrt|S|dkrR|jtkr4t|St|d|j|j	|jd�S|dkr�|jt
krlt|St|d|j|j	|jd�SdS)Nr'�9r/)�roundingrrrrrArr:�prec�EmaxrrBr*r*r,r3ws �
�
�zOverflow.handleNr4r*r*r*r,rasrc@seZdZdS)rNr8r*r*r*r,r�src@seZdZdS)rNr8r*r*r*r,r�srZdecimal_contextcCs6z
t��WSty0t�}t�|�|YS0dSr))�_current_context_var�get�LookupErrorr�set�r2r*r*r,r�s

rcCs,|tttfvr|��}|��t�|�dSr))rrr�copy�clear_flagsrHrKrLr*r*r,r�srcCs|durt�}t|�Sr))r�_ContextManager)�ctxr*r*r,r�s$rc
@s�eZdZdZd�dd�Zedd��Zdd	�Zd
d�Zd�dd
�Z	dd�Z
dd�Zdd�Zd�dd�Z
d�dd�Zd�dd�Zd�dd�Zd�dd�Zd�dd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd�d)d*�Zd�d+d,�Zd�d-d.�Zd�d/d0�Zd�d2d3�Zd�d4d5�ZeZd�d6d7�Z�dd8d9�Z�dd:d;�Z e Z!�dd<d=�Z"d>d?�Z#�dd@dA�Z$�ddBdC�Z%�ddDdE�Z&�ddFdG�Z'�ddHdI�Z(�ddJdK�Z)�d	dLdM�Z*�d
dNdO�Z+dPdQ�Z,dRdS�Z-e-Z.e/dTdU��Z0e/dVdW��Z1dXdY�Z2dZd[�Z3d\d]�Z4d^d_�Z5d`da�Z6dbdc�Z7ddde�Z8dfdg�Z9dhdi�Z:djdk�Z;dldm�Z<dndo�Z=e>e6e7e8e9e:e;e<e=dp�Z?�ddqdr�Z@dsdt�ZAdudv�ZB�ddwdx�ZC�d
dydz�ZDd{d|�ZE�dd}d~�ZF�ddd��ZG�dd�d��ZH�dd�d��ZI�dd�d��ZJd�d��ZKd�d��ZL�dd�d��ZM�dd�d��ZNeNZO�dd�d��ZP�dd�d��ZQ�dd�d��ZRd�d��ZSd�d��ZTd�d��ZUd�d��ZV�dd�d��ZW�dd�d��ZX�dd�d��ZYd�d��ZZd�d��Z[�dd�d��Z\�dd�d��Z]d�d��Z^d�d��Z_d�d��Z`d�d��Za�dd�d��Zbd�d��Zcd�d��Zdd�d��Ze�dd�d��Zfd�d��Zgd�d��Zh�dd�d„Zid�dĄZj�d d�dƄZk�d!d�dȄZld�dʄZmd�d̄Zn�d"d�d΄Zo�d#d�dЄZp�d$d�d҄Zq�d%d�dԄZr�d&d�dքZs�d'd�d؄Zt�d(d�dڄZu�d)d�d܄Zv�d*d�dބZw�d+d�d�Zxd�d�Zy�d,d�d�Zz�d-d�d�Z{�d.d�d�Z|d�d�Z}d�d�Z~d�d�Z�d/d�d�Z�dS(0r)�_expr<r;�_is_special�0NcCs�t�|�}t|t��r$t|���dd��}|durP|dur@t�}|�t	d|�S|�
d�dkrfd|_nd|_|�
d�}|dur�|�
d	�p�d}t|�
d
�p�d�}tt||��|_
|t|�|_d|_nZ|�
d
�}|du�rtt|p�d���d�|_
|�
d��rd|_nd|_nd|_
d|_d|_|St|t��rf|dk�rBd|_nd|_d|_tt|��|_
d|_|St|t��r�|j|_|j|_|j
|_
|j|_|St|t��r�|j|_t|j�|_
t|j�|_d|_|St|ttf��r"t|�dk�r�td��t|dt��r|ddv�std��|d|_|ddk�rHd|_
|d|_d|_n�g}	|dD]R}
t|
t��r�d|
k�r|dk�r�nn|	�s�|
dk�r�|	�|
�ntd���qT|ddv�r�d�tt|	��|_
|d|_d|_nDt|dt��rd�tt|	�p�dg��|_
|d|_d|_ntd��|St|t��rx|du�r>t�}|�td�t�|�}|j|_|j|_|j
|_
|j|_|St d|��dS)N�_�zInvalid literal for Decimal: %rrC�-r/r'�intZfrac�exprSF�diag�signal�Nr9�FT�ztInvalid tuple size in creation of Decimal from list or tuple.  The list or tuple should have exactly three elements.�r'r/z|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.�r9r[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�groupr;rWr<�lenrQrR�lstrip�absr�_WorkReprCrX�list�tuple�
ValueError�append�join�map�floatr�
from_float�	TypeError)�cls�valuer2r1�m�intpart�fracpartrXrY�digits�digitr*r*r,rd
s�
�





(


�
zDecimal.__new__cCs�t|t�r,|dkrdnd}d}tt|��}nzt|t�r�t�|�sJt�|�rV|t|��St�	d|�dkrld}nd}t|��
�\}}|��d}t|d|�}ntd��t
|||�}|tur�|S||�SdS)Nr'r/g�?�zargument must be int or float.)rerWrfrnrv�_mathZisinfZisnan�reprZcopysign�as_integer_ratio�
bit_lengthrxr:r)ry�frC�k�coeffr9�d�resultr*r*r,rw�s$

zDecimal.from_floatcCs(|jr$|j}|dkrdS|dkr$dSdS)Nr9r/r[r_r')rRrQ)r1rXr*r*r,�_isnan�szDecimal._isnancCs|jdkr|jrdSdSdS)Nr\���r/r')rQr;�r1r*r*r,�_isinfinity�s

zDecimal._isinfinitycCs||��}|durd}n|��}|s&|rx|dur4t�}|dkrJ|�td|�S|dkr`|�td|�S|rn|�|�S|�|�SdS)NFr_�sNaNr')r�rrjr	r=)r1�otherr2�self_is_nan�other_is_nanr*r*r,�_check_nans�s&
��

zDecimal._check_nanscCsv|durt�}|js|jrr|��r0|�td|�S|��rF|�td|�S|��r\|�td|�S|��rr|�td|�SdS)Nzcomparison involving sNaNzcomparison involving NaNr')rrR�is_snanrjr	�is_qnan�r1r�r2r*r*r,�_compare_check_nans	s0����zDecimal._compare_check_nanscCs|jp|jdkS�NrS�rRr<r�r*r*r,�__bool__*szDecimal.__bool__cCs|js|jr8|��}|��}||kr(dS||kr4dSdS|sP|sDdSd|jS|s^d|jS|j|jkrndS|j|jkr~dS|��}|��}||kr�|jd|j|j}|jd|j|j}||kr�dS||kr�d|jSd|jSn ||k�rd|jSd|jSdS)Nr'r�r/rS)rRr�r;�adjustedr<rQ)r1r�Zself_infZ	other_inf�
self_adjustedZother_adjusted�self_paddedZother_paddedr*r*r,�_cmp1s>


zDecimal._cmpcCs<t||dd�\}}|tur|S|�||�r.dS|�|�dkS)NT)�equality_opFr')�_convert_for_comparison�NotImplementedr�r�r�r*r*r,�__eq__qszDecimal.__eq__cCs<t||�\}}|tur|S|�||�}|r.dS|�|�dkS�NFr'�r�r�r�r��r1r�r2r?r*r*r,�__lt__yszDecimal.__lt__cCs<t||�\}}|tur|S|�||�}|r.dS|�|�dkSr�r�r�r*r*r,�__le__�szDecimal.__le__cCs<t||�\}}|tur|S|�||�}|r.dS|�|�dkSr�r�r�r*r*r,�__gt__�szDecimal.__gt__cCs<t||�\}}|tur|S|�||�}|r.dS|�|�dkSr�r�r�r*r*r,�__ge__�szDecimal.__ge__cCs>t|dd�}|js|r0|jr0|�||�}|r0|St|�|��S�NT��raiseit)�_convert_otherrRr�rr�r�r*r*r,�compare�szDecimal.comparecCs�|jr4|��rtd��n|��r$tS|jr0tStS|jdkrNtd|jt	�}ntt
|jt	�}t|j�|t	}|dkr||n|}|dkr�dS|S)Nz"Cannot hash a signaling NaN value.r'�
r����)
rRr�rx�is_nan�_PyHASH_NANr;�_PyHASH_INFrQ�pow�_PyHASH_MODULUS�
_PyHASH_10INVrWr<)r1Zexp_hashZhash_r?r*r*r,�__hash__�s

zDecimal.__hash__cCst|jttt|j��|j�Sr))rr;rqrurWr<rQr�r*r*r,�as_tuple�szDecimal.as_tuplecCs�|jr |��rtd��ntd��|s(dSt|j�}|jdkrR|d|jd}}nn|j}|dkr�|ddkr�|d}|d8}qZ|j}t||@��d|�}|r�||L}||8}d||>}|j	r�|}||fS)Nz#cannot convert NaN to integer ratioz(cannot convert Infinity to integer ratior^r'r�r/r�)
rRr�rr�
OverflowErrorrWr<rQ�minr�r;)r1r9r�Zd5Zd2Zshift2r*r*r,r��s,



zDecimal.as_integer_ratiocCsdt|�S)Nz
Decimal('%s'))rfr�r*r*r,�__repr__szDecimal.__repr__Fc	Csbddg|j}|jrL|jdkr&|dS|jdkr>|d|jS|d|jS|jt|j�}|jdkrt|d	krt|}n6|s~d
}n,|jdkr�|d
dd
}n|d
dd
}|dkr�d}d
d||j}nL|t|j�kr�|jd|t|j�}d}n |jd|�}d
|j|d�}||k�r(d}n*|du�r8t�}ddg|jd||}||||S)NrUrVr\ZInfinityr9�NaNr�r'���r/rSr]�.�e�Ez%+d)r;rRrQr<rlr�capitals)	r1�engr2rC�
leftdigits�dotplacer|r}rXr*r*r,�__str__s:




zDecimal.__str__cCs|jd|d�S)NT)r�r2)r��r1r2r*r*r,�
to_eng_string;szDecimal.to_eng_stringcCsR|jr|j|d�}|r|S|dur(t�}|s@|jtkr@|��}n|��}|�|�S�NrL)rRr�rrEr�copy_abs�copy_negate�_fix�r1r2r?r*r*r,�__neg__Ds
zDecimal.__neg__cCsR|jr|j|d�}|r|S|dur(t�}|s@|jtkr@|��}nt|�}|�|�Sr�)rRr�rrErr�rr�r�r*r*r,�__pos__Zs
zDecimal.__pos__TcCsJ|s|��S|jr&|j|d�}|r&|S|jr:|j|d�}n|j|d�}|Sr�)r�rRr�r;r�r�)r1�roundr2r?r*r*r,�__abs__oszDecimal.__abs__c
Csht|�}|tur|S|dur"t�}|js.|jr�|�||�}|rB|S|��rr|j|jkrj|��rj|�td�St	|�S|��r�t	|�St
|j|j�}d}|jt
kr�|j|jkr�d}|s�|s�t
|j|j�}|r�d}t|d|�}|�|�}|S|�st||j|jd�}|�||j�}|�|�}|S|�sVt||j|jd�}|�||j�}|�|�}|St|�}t|�}t|||j�\}}t�}	|j|jk�r�|j|jk�r�t|d|�}|�|�}|S|j|jk�r�||}}|jdk�r�d|	_|j|j|_|_nd|	_n&|jdk�rd|	_d\|_|_nd|	_|jdk�r<|j|j|	_n|j|j|	_|j|	_t	|	�}|�|�}|S)Nz
-INF + INFr'r/rS)r'r')r�r�rrRr�r�r;rjr	rr�rQrErr:r��maxrF�_rescalero�
_normalizerCrWrX)
r1r�r2r?rXZnegativezerorC�op1�op2r�r*r*r,�__add__�s|





zDecimal.__add__cCsHt|�}|tur|S|js |jr6|j||d�}|r6|S|j|��|d�Sr�)r�r�rRr�r�r�r�r*r*r,�__sub__�szDecimal.__sub__cCs"t|�}|tur|S|j||d�Sr�)r�r�r�r�r*r*r,�__rsub__�szDecimal.__rsub__cCs@t|�}|tur|S|dur"t�}|j|jA}|js:|jr�|�||�}|rN|S|��rn|sf|�td�St	|S|��r�|s�|�td�St	|S|j
|j
}|r�|s�t|d|�}|�|�}|S|j
dkr�t||j
|�}|�|�}|S|j
dk�r
t||j
|�}|�|�}|St|�}t|�}t|t|j|j�|�}|�|�}|S)Nz(+-)INF * 0z0 * (+-)INFrS�1)r�r�rr;rRr�r�rjr	rArQr:r�r<rorfrW)r1r�r2Z
resultsignr?Z	resultexpr�r�r*r*r,�__mul__�sH




zDecimal.__mul__cCs�t|�}|turtS|dur"t�}|j|jA}|js:|jr�|�||�}|rN|S|��rj|��rj|�td�S|��rzt	|S|��r�|�t
d�t|d|���S|s�|s�|�t
d�S|�td|�S|s�|j|j}d}n�t|j�t|j�|jd}|j|j|}t|�}t|�}	|dk�r:t|jd||	j�\}}
nt|j|	jd|�\}}
|
�rt|d	dk�r�|d7}n8|j|j}||k�r�|ddk�r�|d}|d7}�q�t|t|�|�}|�|�S)
Nz(+-)INF/(+-)INFzDivision by infinityrSz0 / 0zx / 0r'r/r�r�)r�r�rr;rRr�r�rjr	rArr:�Etinyrr
rQrlr<rFro�divmodrWrfr�)r1r�r2rCr?rXr��shiftr�r��	remainder�	ideal_expr*r*r,�__truediv__,sP

zDecimal.__truediv__cCs|j|jA}|��r|j}nt|j|j�}|��|��}|rN|��sN|dkrht|dd�|�||j�fS||jk�r
t	|�}t	|�}|j
|j
kr�|jd|j
|j
9_n|jd|j
|j
9_t|j|j�\}}	|d|jk�r
t|t
|�d�t|jt
|	�|�fS|�td�}
|
|
fS)Nr�rSr'r�z%quotient too large in //, % or divmod)r;r�rQr�r�r:r�rErFrorXrWr�rfrjr)r1r�r2rCr��expdiffr�r��q�rr?r*r*r,�_dividegs0
���zDecimal._dividecCs"t|�}|tur|S|j||d�Sr�)r�r�r�r�r*r*r,�__rtruediv__�szDecimal.__rtruediv__cCs�t|�}|tur|S|dur"t�}|�||�}|r:||fS|j|jA}|��r~|��rj|�td�}||fSt||�td�fS|s�|s�|�t	d�}||fS|�t
d|�|�td�fS|�||�\}}|�|�}||fS)Nzdivmod(INF, INF)�INF % xzdivmod(0, 0)�x // 0�x % 0)
r�r�rr�r;r�rjr	rArr
r�r�)r1r�r2r?rCZquotientr�r*r*r,�
__divmod__�s4
�
�
zDecimal.__divmod__cCs"t|�}|tur|S|j||d�Sr�)r�r�r�r�r*r*r,�__rdivmod__�szDecimal.__rdivmod__cCs�t|�}|tur|S|dur"t�}|�||�}|r6|S|��rJ|�td�S|sj|r^|�td�S|�td�S|�||�d}|�	|�}|S)Nr�r�z0 % 0r/)
r�r�rr�r�rjr	rr�r�)r1r�r2r?r�r*r*r,�__mod__�s"
zDecimal.__mod__cCs"t|�}|tur|S|j||d�Sr�)r�r�r�r�r*r*r,�__rmod__�szDecimal.__rmod__cCs�|durt�}t|dd�}|�||�}|r.|S|��rB|�td�S|sb|rV|�td�S|�td�S|��r|t|�}|�|�St	|j
|j
�}|s�t|jd|�}|�|�S|�
�|�
�}||jdkr�|�t�S|dkr�|�||j�}|�|�St|�}t|�}|j|jk�r(|jd	|j|j9_n|jd	|j|j9_t|j|j�\}}	d
|	|d@|jk�r~|	|j8}	|d7}|d	|jk�r�|�t�S|j}
|	dk�r�d|
}
|	}	t|
t|	�|�}|�|�S)NTr�zremainder_near(infinity, x)zremainder_near(x, 0)zremainder_near(0, 0)rSr/r�r�r_r')rr�r�r�rjr	rrr�r�rQr:r;r�rFrr�rErorXrWr�rf)r1r�r2r?�ideal_exponentr�r�r�r�r�rCr*r*r,�remainder_near�s`���






zDecimal.remainder_nearcCs�t|�}|tur|S|dur"t�}|�||�}|r6|S|��rb|��rR|�td�St|j|jAS|s�|r�|�t	d|j|jA�S|�t
d�S|�||�dS)Nz
INF // INFr�z0 // 0r')r�r�rr�r�rjr	rAr;r
rr�r�r*r*r,�__floordiv__'s&
�zDecimal.__floordiv__cCs"t|�}|tur|S|j||d�Sr�)r�r�r�r�r*r*r,�
__rfloordiv__CszDecimal.__rfloordiv__cCs8|��r(|��rtd��|jr"dnd}nt|�}t|�S)Nz%Cannot convert signaling NaN to floatz-nan�nan)r�r�rrr;rfrv�r1�sr*r*r,�	__float__JszDecimal.__float__cCst|jr(|��rtd��n|��r(td��d|j}|jdkrT|t|j�d|jS|t|jd|j�pjd�SdS)NzCannot convert NaN to integerz"Cannot convert infinity to integerr�r'r�rS)	rRr�rrr�r�r;rQrWr<r�r*r*r,�__int__Ts


zDecimal.__int__cCs|Sr)r*r�r*r*r,�realcszDecimal.realcCstd�S�Nr'�rr�r*r*r,�imaggszDecimal.imagcCs|Sr)r*r�r*r*r,�	conjugatekszDecimal.conjugatecCstt|��Sr))�complexrvr�r*r*r,�__complex__nszDecimal.__complex__cCsR|j}|j|j}t|�|krJ|t|�|d��d�}t|j||jd�St|�S)NrST)	r<rF�clamprlrmr:r;rQr)r1r2ZpayloadZmax_payload_lenr*r*r,r=qszDecimal._fix_nancCsX|jr |��r|�|�St|�S|��}|��}|s�|j|g|j}tt	|j
|�|�}||j
krx|�t�t
|jd|�St|�St|j�|j
|j}||kr�|�td|j�}|�t�|�t�|S||k}|r�|}|j
|k�r�t|j�|j
|}	|	dk�rt
|jd|d�}d}	|j|j}
|
||	�}|jd|	��p>d}|dk�r~tt|�d�}t|�|jk�r~|dd�}|d7}||k�r�|�td|j�}nt
|j||�}|�r�|�r�|�t�|�r�|�t�|�r�|�t�|�t�|�s�|�t�|S|�r|�t�|jdk�rP|j
|k�rP|�t�|jd|j
|}
t
|j|
|�St|�S)NrS�
above Emaxr'r�r/r�)rRr�r=rr��EtoprGr�r�r�rQrjrr:r;rlr<rFrrr�_pick_rounding_functionrErfrWrr
)r1r2r�r��exp_maxZnew_expZexp_minr?Zself_is_subnormalr~Zrounding_method�changedr�r�r*r*r,r�}sn
















zDecimal._fixcCst|j|�rdSdSdS)Nr'r�)�
_all_zerosr<�r1rFr*r*r,�_round_down�szDecimal._round_downcCs|�|�Sr))rrr*r*r,�	_round_up�szDecimal._round_upcCs*|j|dvrdSt|j|�r"dSdSdS)NZ56789r/r'r�)r<rrr*r*r,�_round_half_up�s
zDecimal._round_half_upcCst|j|�rdS|�|�SdS)Nr���_exact_halfr<rrr*r*r,�_round_half_down�szDecimal._round_half_downcCs8t|j|�r*|dks&|j|ddvr*dS|�|�SdS)Nr'r/�02468r�rrr*r*r,�_round_half_even�s��zDecimal._round_half_evencCs |jr|�|�S|�|�SdSr)�r;rrr*r*r,�_round_ceilings
zDecimal._round_ceilingcCs |js|�|�S|�|�SdSr)rrr*r*r,�_round_floor
s
zDecimal._round_floorcCs0|r |j|ddvr |�|�S|�|�SdS)Nr/Z05)r<rrr*r*r,�_round_05ups
zDecimal._round_05up)rrrrrrrrcCsb|dur2t|t�std��tdd|�}|�|�S|jrR|��rJtd��ntd��t|�	dt
��S)Nz+Second argument to round should be integralr'r��cannot round a NaN�cannot round an infinity)rerWrxr:�quantizerRr�rrr�r�r)r1r9rXr*r*r,�	__round__&s/


zDecimal.__round__cCs0|jr |��rtd��ntd��t|�dt��S�Nrrr')rRr�rrr�rWr�rr�r*r*r,�	__floor__ds

zDecimal.__floor__cCs0|jr |��rtd��ntd��t|�dt��Sr)rRr�rrr�rWr�rr�r*r*r,�__ceil__ss

zDecimal.__ceil__cCst|dd�}t|dd�}|js$|jr�|dur2t�}|jdkrJ|�td|�S|jdkrb|�td|�S|jdkrr|}nf|jdkr�|}nV|jdkr�|s�|�td�St|j|jA}n*|jdkr�|s�|�td�St|j|jA}n0t|j|jAt	t
|j�t
|j��|j|j�}|�||�S)	NTr�r[r�r9r\zINF * 0 in fmaz0 * INF in fma)
r�rRrrQrjr	rAr;r:rfrWr<r�)r1r�Zthirdr2�productr*r*r,�fma�s<




�
�
�zDecimal.fmacCs�t|�}|tur|St|�}|tur(|S|dur6t�}|��}|��}|��}|sZ|sZ|r�|dkrp|�td|�S|dkr�|�td|�S|dkr�|�td|�S|r�|�|�S|r�|�|�S|�|�S|��r�|��r�|��s�|�td�S|dkr�|�td�S|�s|�td�S|��|j	k�r(|�td�S|�s@|�s@|�td�S|�
��rPd}n|j}tt
|��}t|���}t|���}	|j
|td	|j|�|}t|	j�D]}
t|d	|�}�q�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�rjr	r=�
_isintegerr�rF�_isevenr;rnrWro�to_integral_valuer�rX�ranger:rf)r1r��modulor2r�r�Z
modulo_is_nanrC�base�exponent�ir*r*r,�
_power_modulo�s����


�������
zDecimal._power_modulocCs�t|�}|j|j}}|ddkr4|d}|d7}qt|�}|j|j}}|ddkrh|d}|d7}qJ|dk�r||9}|ddkr�|d}|d7}qz|dkr�dS|d|}	|jdkr�|	}	|��r�|jdkr�|jt|�}
t|	|
|d�}nd}tddd||	|�S|jdk�r�|d}|dv�r�||@|k�rBdSt	|�d}
|dd}|t
t|��k�rpdSt|
||�}
t|||�}|
du�s�|du�r�dS|
|k�r�dSd	|
}n�|d	k�r�t	|�d
d}
t
d	|
|�\}}|�r�dS|d	dk�r|d	}|
d8}
�q�|dd}|t
t|��k�r6dSt|
||�}
t|||�}|
du�sf|du�rjdS|
|k�rxdSd|
}ndS|d|k�r�dS|
|}tdt|�|�S|dk�r�|d|d}}n�|dk�r�t
tt||���|k�r�dSt	|�}|dk�r,t
tt|�|��|k�r,dS|d|}}|d|dk�r\dk�rtnn|d}|d}�q<|d	|d	k�r�dk�r�nn|d	}|d	}�qt|dk�rX|dk�r�||k�r�dSt
||�\}}|dk�r�dSdt	|�|>}t
|||d�\}}||k�r$�q<n||d||}�q�||k�rP|dk�sTdS|}|dk�r|||d
t|�k�r|dS||}||9}|d|k�r�dSt|�}|���r�|jdk�r�|jt|�}
t||
|t
|��}nd}td|d|||�S)Nr�r'r/r�rS)r_����]�Ar��r]r_�d)rorWrXrCrr;rQr�r:�_nbitsrlrf�_decimal_lshift_exactr�rn�	_log10_lb)r1r��p�x�xc�xe�y�yc�yerr�ZzerosZ
last_digitr�Zemaxr�r{r9Zxc_bits�rem�ar�r�Zstr_xcr*r*r,�_power_exacts�:












&&$$


 zDecimal._power_exactcCs4|dur|�|||�St|�}|tur*|S|dur8t�}|�||�}|rL|S|sd|s`|�td�StSd}|jdkr�|�	�r�|�
�s�d}n|r�|�td�S|��}|s�|jdkr�t|dd�St
|S|��r�|jdkr�t
|St|dd�S|tk�r�|�	��rZ|jdk�rd}n||jk�r"|j}nt|�}|j|}|d|jk�rxd|j}|�t�n|�t�|�t�d|j}t|dd||�S|��}|���r�|jdk|dkk�r�t|dd�St
|Sd}d}	|��|��}
|dk|jdkk�r|
tt|j��k�rHt|d|jd�}n,|��}|
tt|��k�rHt|d|d�}|du�r�|�||jd�}|du�r�|dk�r�td|j|j�}d}	|du�r8|j}t|�}
|
j|
j}}t|�}|j|j}}|jdk�r�|}d	}t||||||�\}}|d
dtt|��|d�r�q(|d	7}�q�t|t|�|�}|	�r&|�	��s&t|j�|jk�r�|jdt|j�}t|j|jd||j|�}|� �}|�!�t"D]}d|j#|<�q�|�$|�}|�t�|j%t&�r�|�t'�|j%t(�r�|�t(d|j�t't&ttt)fD]}|j%|�r|�|��qn
|�$|�}|S)
Nz0 ** 0r'r/z+x ** y with x negative and y not an integerrSr�FTr]r�r�r�)*r!r�r�rr�rjr	�_Oner;rrr�r:rAr�rFrWrQrrr��_log10_exp_boundrlrfrGr�r5r<rorXrC�_dpowerrMrN�_signals�trapsr��flagsr
rrr)r1r�rr2r?Zresult_signZ
multiplierrXZself_adj�exact�boundr�r,r-r.r/r0r1r2�extrar�r�Z
newcontextZ	exceptionr*r*r,�__pow__�s�
�













"�



zDecimal.__pow__cCs"t|�}|tur|S|j||d�Sr�)r�r�r?r�r*r*r,�__rpow__�	szDecimal.__rpow__cCs�|durt�}|jr(|j|d�}|r(|S|�|�}|��r>|S|sPt|jdd�S|j|��g|j	}t
|j�}|j}|j|ddkr�||kr�|d7}|d8}qtt|j|jd|�|�S)NrLrSr'r/)
rrRr�r�r�r:r;rGr�r�rlr<rQ)r1r2r?�dupr�endrXr*r*r,�	normalize�	s$


zDecimal.normalizecCs�t|dd�}|durt�}|dur(|j}|js4|jr||�||�}|rH|S|��sX|��r||��rp|��rpt|�S|�td�S|�	�|j
kr�|jks�n|�td�S|s�t|j
d|j
�}|�|�S|��}||jkr�|�td�S||j
d|jk�r|�td�S|�|j
|�}|��|jk�r.|�td�St|j�|jk�rL|�td�S|�rl|��|jk�rl|�t�|j
|j
k�r�||k�r�|�t�|�t�|�|�}|S)	NTr�zquantize with one INFz)target exponent out of bounds in quantizerSz9exponent of quantize result too large for current contextr/z7quantize result has too many digits for current context)r�rrErRr�r�rrjr	r�rQrGr:r;r�r�rFr�rlr<�Eminr
rr)r1rXrEr2r?r�r*r*r,r�	s`��

����




zDecimal.quantizecCsDt|dd�}|js|jr8|��r(|��p6|��o6|��S|j|jkSr�)r�rRr��is_infiniterQr�r*r*r,�same_quantum%
s	�zDecimal.same_quantumcCs�|jrt|�S|s t|jd|�S|j|krHt|j|jd|j||�St|j�|j|}|dkrzt|jd|d�}d}|j|}|||�}|jd|�p�d}|dkr�tt	|�d�}t|j||�S)NrSr'r�r/)
rRrr:r;rQr<rlr�rfrW)r1rXrEr~Z
this_functionrr�r*r*r,r�4
s$
�

zDecimal._rescalecCsf|dkrtd��|js|s"t|�S|�|��d||�}|��|��krb|�|��d||�}|S)Nr'z'argument should be at least 1 in _roundr/)rrrRrr�r�)r1�placesrEr?r*r*r,�_roundV
s

zDecimal._roundcCs�|jr"|j|d�}|r|St|�S|jdkr4t|�S|sFt|jdd�S|durTt�}|durb|j}|�d|�}||kr�|�	t
�|�	t�|S)NrLr'rS)rRr�rrQr:r;rrEr�rjrr�r1rEr2r?r*r*r,�to_integral_exactm
s$



zDecimal.to_integral_exactcCs`|durt�}|dur|j}|jr>|j|d�}|r6|St|�S|jdkrPt|�S|�d|�SdS)NrLr')rrErRr�rrQr�rIr*r*r,r�
s
zDecimal.to_integral_valuecCs�|durt�}|jrB|j|d�}|r(|S|��rB|jdkrBt|�S|sdt|jd|jd�}|�|�S|jdkrz|�	t
d�S|jd}t|�}|j
d?}|j
d@r�|jd}t|j�d?d}n|j}t|j�dd?}||}|dkr�|d|9}d	}	nt|d|�\}}
|
}	||8}d|}||}||k�r:�qJn||d?}�q"|	�oZ|||k}	|	�r�|dk�rz|d|}n|d|9}||7}n|d
dk�r�|d7}tdt|�|�}|��}|�t�}
|�|�}|
|_|S)NrLr'rSr_r/zsqrt(-x), x > 0r�r(Tr�)rrRr�r�r;rr:rQr�rjr	rFrorXrWrlr<r�rf�
_shallow_copy�
_set_roundingrrE)r1r2r?rF�opr��c�lr�r<r�r9r�rEr*r*r,�sqrt�
s^










zDecimal.sqrtcCs�t|dd�}|durt�}|js&|jr~|��}|��}|s>|r~|dkrX|dkrX|�|�S|dkrr|dkrr|�|�S|�||�S|�|�}|dkr�|�|�}|dkr�|}n|}|�|�S�NTr�r/r'r��r�rrRr�r�r�r��
compare_total�r1r�r2ZsnZonrNr?r*r*r,r�s&


	
zDecimal.maxcCs�t|dd�}|durt�}|js&|jr~|��}|��}|s>|r~|dkrX|dkrX|�|�S|dkrr|dkrr|�|�S|�||�S|�|�}|dkr�|�|�}|dkr�|}n|}|�|�SrQrRrTr*r*r,r�*s&



zDecimal.mincCs8|jr
dS|jdkrdS|j|jd�}|dt|�kS)NFr'TrS)rRrQr<rl)r1�restr*r*r,rLs
zDecimal._isintegercCs&|r|jdkrdS|jd|jdvS)Nr'Tr�r
)rQr<r�r*r*r,rUszDecimal._isevencCs0z|jt|j�dWSty*YdS0dS)Nr/r')rQrlr<rxr�r*r*r,r�[szDecimal.adjustedcCs|Sr)r*r�r*r*r,�	canonicalcszDecimal.canonicalcCs.t|dd�}|�||�}|r |S|j||d�S�NTr�rL)r�r�r�r�r*r*r,�compare_signalks
zDecimal.compare_signalcCs`t|dd�}|jr|jstS|js,|jr,tS|j}|��}|��}|sL|�r||kr�t|j�|jf}t|j�|jf}||kr�|r�tStS||kr�|r�tStStS|r�|dkr�tS|dkr�tS|dkr�tS|dkr�tSn2|dkr�tS|dkr�tS|dkr�tS|dk�rtS||k�rtS||k�r$tS|j|jk�r@|�r<tStS|j|jk�r\|�rXtStStS)NTr�r/r_)	r�r;�_NegativeOner6r�rlr<�_ZerorQ)r1r�r2rCZself_nanZ	other_nanZself_keyZ	other_keyr*r*r,rSwsf



zDecimal.compare_totalcCs&t|dd�}|��}|��}|�|�Sr�)r�r�rS)r1r�r2r��or*r*r,�compare_total_mag�szDecimal.compare_total_magcCstd|j|j|j�Sr�)r:r<rQrRr�r*r*r,r��szDecimal.copy_abscCs2|jrtd|j|j|j�Std|j|j|j�SdS)Nr'r/)r;r:r<rQrRr�r*r*r,r��szDecimal.copy_negatecCs"t|dd�}t|j|j|j|j�Sr�)r�r:r;r<rQrRr�r*r*r,�	copy_sign�s
�zDecimal.copy_signcCs�|durt�}|j|d�}|r"|S|��dkr2tS|s:tS|��dkrNt|�S|j}|��}|jdkr�|t	t
|jdd��kr�tdd|jd�}�n0|jdkr�|t	t
|�
�dd��kr�tdd|�
�d�}n�|jdk�r||k�rtddd|dd|�}n�|jdk�rD||dk�rDtdd|d|d�}n�t|�}|j|j}}|jdk�rl|}d}t||||�\}	}
|	d	d
t	t
|	��|d�r��q�|d7}�qptdt
|	�|
�}|��}|�t�}|�|�}||_|S)NrLr�r/r'r]r�rSrDr�r�)rr�r�rZr6rrFr�r;rlrfrGr:r�rorWrXrC�_dexprKrLrr�rE)r1r2r?r,�adjrMrNr�r>r�rXrEr*r*r,rX�sH$( "

zDecimal.expcCsdS)NTr*r�r*r*r,�is_canonical'szDecimal.is_canonicalcCs|jSr))rRr�r*r*r,�	is_finite/szDecimal.is_finitecCs
|jdkS)Nr\�rQr�r*r*r,rE7szDecimal.is_infinitecCs
|jdvS)Nrarbr�r*r*r,r�;szDecimal.is_nancCs*|js
|sdS|durt�}|j|��kS�NF)rRrrDr�r�r*r*r,�	is_normal?s

zDecimal.is_normalcCs
|jdkS)Nr9rbr�r*r*r,r�GszDecimal.is_qnancCs
|jdkS�Nr/)r;r�r*r*r,�	is_signedKszDecimal.is_signedcCs
|jdkS)Nr[rbr�r*r*r,r�OszDecimal.is_snancCs*|js
|sdS|durt�}|��|jkSrc)rRrr�rDr�r*r*r,�is_subnormalSs

zDecimal.is_subnormalcCs|jo|jdkSr�r�r�r*r*r,�is_zero[szDecimal.is_zerocCs�|jt|j�d}|dkr4tt|dd��dS|dkrXttd|dd��dSt|�}|j|j}}|dkr�t|d|�}t|�}t|�t|�||kS|ttd||��dS)Nr/�r�r�r�r'�rQrlr<rfrorWrX�r1r_rMrNr��numZdenr*r*r,�
_ln_exp_bound_szDecimal._ln_exp_boundc
Cs|durt�}|j|d�}|r"|S|s*tS|��dkr:tS|tkrFtS|jdkr\|�t	d�St
|�}|j|j}}|j
}||��d}t|||�}|ddttt|���|dr�q�|d7}q�tt|dk�tt|��|�}|��}|�t�}	|�|�}|	|_|S)	NrLr/zln of a negative valuer_r�r�r]r')rr��_NegativeInfinityr��	_Infinityr6rZr;rjr	rorWrXrFrm�_dlogrlrfrnr:rKrLrr�rE�
r1r2r?rMrNr�r,rGr�rEr*r*r,�lnxs:
�$


z
Decimal.lncCs�|jt|j�d}|dkr,tt|��dS|dkrHttd|��dSt|�}|j|j}}|dkr�t|d|�}td|�}t|�t|�||kdStd||�}t|�||dkdS)	Nr/r�r�r'r���r_Z231rjrkr*r*r,r7�szDecimal._log10_exp_boundc
CsF|durt�}|j|d�}|r"|S|s*tS|��dkr:tS|jdkrP|�td�S|jddkr�|jdd�dt	|j�dkr�t
|jt	|j�d�}n�t|�}|j
|j}}|j}||��d}t|||�}|dd	t	tt|���|dr��q|d
7}q�tt
|dk�tt|��|�}|��}|�t�}	|�|�}|	|_|S)NrLr/zlog10 of a negative valuer'r�rSr_r�r�r])rr�rnr�ror;rjr	r<rlrrQrorWrXrFr7�_dlog10rfrnr:rKrLrr�rErqr*r*r,�log10�s:
�.$


z
Decimal.log10cCsV|j|d�}|r|S|dur"t�}|��r.tS|s@|�tdd�St|���}|�|�S)NrLzlogb(0)r/)	r�rr�rorjr
rr�r�r�r*r*r,�logb�s	zDecimal.logbcCs6|jdks|jdkrdS|jD]}|dvrdSqdS)Nr'FZ01T)r;rQr<)r1�digr*r*r,�
_islogical
s
zDecimal._islogicalcCs�|jt|�}|dkr$d||}n|dkr<||jd�}|jt|�}|dkr`d||}n|dkrx||jd�}||fS)Nr'rS)rFrl)r1r2�opa�opbZdifr*r*r,�
_fill_logical'
szDecimal._fill_logicalcCsz|durt�}t|dd�}|��r*|��s4|�t�S|�||j|j�\}}d�dd�t||�D��}t	d|�
d�ptdd�S)NTr�rUcSs$g|]\}}tt|�t|�@��qSr*�rfrW��.0r4�br*r*r,�
<listcomp>B
r.z'Decimal.logical_and.<locals>.<listcomp>r'rS�rr�rxrjr	r{r<rt�zipr:rm�r1r�r2ryrzr�r*r*r,�logical_and4
s
zDecimal.logical_andcCs(|durt�}|�tdd|jd�|�S)Nr'r�)r�logical_xorr:rFr�r*r*r,�logical_invertE
s
�zDecimal.logical_invertcCsz|durt�}t|dd�}|��r*|��s4|�t�S|�||j|j�\}}d�dd�t||�D��}t	d|�
d�ptdd�S)NTr�rUcSs$g|]\}}tt|�t|�B��qSr*r|r}r*r*r,r�Z
r.z&Decimal.logical_or.<locals>.<listcomp>r'rSr�r�r*r*r,�
logical_orL
s
zDecimal.logical_orcCsz|durt�}t|dd�}|��r*|��s4|�t�S|�||j|j�\}}d�dd�t||�D��}t	d|�
d�ptdd�S)NTr�rUcSs$g|]\}}tt|�t|�A��qSr*r|r}r*r*r,r�k
r.z'Decimal.logical_xor.<locals>.<listcomp>r'rSr�r�r*r*r,r�]
s
zDecimal.logical_xorcCs�t|dd�}|durt�}|js&|jr~|��}|��}|s>|r~|dkrX|dkrX|�|�S|dkrr|dkrr|�|�S|�||�S|���|���}|dkr�|�|�}|dkr�|}n|}|�|�SrQ�	r�rrRr�r�r�r�r�rSrTr*r*r,�max_magn
s&


zDecimal.max_magcCs�t|dd�}|durt�}|js&|jr~|��}|��}|s>|r~|dkrX|dkrX|�|�S|dkrr|dkrr|�|�S|�||�S|���|���}|dkr�|�|�}|dkr�|}n|}|�|�SrQr�rTr*r*r,�min_mag�
s&


zDecimal.min_magcCs�|durt�}|j|d�}|r"|S|��dkr2tS|��dkrTtdd|j|���S|��}|�t	�|�
�|�|�}||kr�|S|�tdd|�
�d�|�S)NrLr�r/r'rDr�)rr�r�rnr:rFr�rMrLr�_ignore_all_flagsr�r�r��r1r2r?Znew_selfr*r*r,�
next_minus�
s$

�zDecimal.next_minuscCs�|durt�}|j|d�}|r"|S|��dkr2tS|��dkrTtdd|j|���S|��}|�t	�|�
�|�|�}||kr�|S|�tdd|�
�d�|�S)NrLr/r�rDr'r�)rr�r�ror:rFr�rMrLrr�r�r�r�r�r*r*r,�	next_plus�
s$

�zDecimal.next_pluscCs�t|dd�}|durt�}|�||�}|r.|S|�|�}|dkrJ|�|�S|dkr^|�|�}n
|�|�}|��r�|�t	d|j
�|�t�|�t�nD|�
�|jkr�|�t�|�t�|�t�|�t�|s�|�t�|S)NTr�r'r�z Infinite result from next_toward)r�rr�r�r]r�r�r�rjrr;rrr�rDrr
r)r1r�r2r?Z
comparisonr*r*r,�next_toward�
s6	


�





zDecimal.next_towardcCs�|��rdS|��rdS|��}|dkr,dS|dkr8dS|��rN|jrJdSdS|dur\t�}|j|d	�rv|jrrd
SdS|jr�dSd
SdS)Nr�r�r/z	+Infinityr�z	-Infinityz-Zeroz+ZerorLz
-Subnormalz
+Subnormalz-Normalz+Normal)r�r�r�rhr;rrg)r1r2�infr*r*r,�number_classs,zDecimal.number_classcCstd�S�Nr�r�r�r*r*r,�radix0sz
Decimal.radixcCs�|durt�}t|dd�}|�||�}|r.|S|jdkrB|�t�S|jt|�kr`|jksln|�t�S|��r|t	|�St|�}|j
}|jt|�}|dkr�d||}n|dkr�||d�}||d�|d|�}t|j
|�d�p�d|j�S�NTr�r'rS�rr�r�rQrjr	rFrWr�rr<rlr:r;rm)r1r�r2r?�torot�rotdig�topadZrotatedr*r*r,�rotate4s.

 
�zDecimal.rotatecCs�|durt�}t|dd�}|�||�}|r.|S|jdkrB|�t�Sd|j|j}d|j|j}|t|�krz|ks�n|�t�S|�	�r�t
|�St|j|j
|jt|��}|�|�}|S)NTr�r'r�r_)rr�r�rQrjr	rGrFrWr�rr:r;r<r�)r1r�r2r?ZliminfZlimsupr�r*r*r,�scalebUs"



zDecimal.scalebcCs|durt�}t|dd�}|�||�}|r.|S|jdkrB|�t�S|jt|�kr`|jksln|�t�S|��r|t	|�St|�}|j
}|jt|�}|dkr�d||}n|dkr�||d�}|dkr�|d|�}n|d|}||jd�}t|j
|�d��p
d|j�Sr�r�)r1r�r2r?r�r�r�Zshiftedr*r*r,r�ns4

 
�z
Decimal.shiftcCs|jt|�ffSr))�	__class__rfr�r*r*r,�
__reduce__�szDecimal.__reduce__cCst|�tur|S|�t|��Sr)��typerr�rfr�r*r*r,�__copy__�szDecimal.__copy__cCst|�tur|S|�t|��Sr)r�)r1�memor*r*r,�__deepcopy__�szDecimal.__deepcopy__cCsJ|durt�}t||d�}|jrXt|j|�}t|���}|ddkrL|d7}t|||�S|ddurvddg|j|d<|ddkr�t	|j|j
|jd�}|j}|d}|du�r|ddvr�|�
|d	|�}nF|dd
vr�|�||�}n*|ddv�rt|j
�|k�r|�
||�}|�s@|jdk�r@|dd
v�r@|�d|�}|jt|j
�}	|ddv�r~|�sx|du�rxd	|}
nd	}
nB|dd
v�r�|	}
n.|ddv�r�|jdk�r�|	d
k�r�|	}
nd	}
|
dk�r�d}d|
|j
}nP|
t|j
�k�r|j
d|
t|j
�}d}n"|j
d|
��p d}|j
|
d�}|	|
}
t|j|||
|�S)N)�_localeconvr��%�g�Gr_�	precision�eEr/zfF%ZgGr'r�rSrU)r�_parse_format_specifierrR�_format_signr;rfr��
_format_alignr�r:r<rQrErHr�rl�_format_number)r1Z	specifierr2r��specrC�bodyrEr�r�r�r|r}rXr*r*r,�
__format__�sZ
 

zDecimal.__format__)rSN)NN)N)N)N)N)N)N)FN)N)N)N)TN)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)NN)N)N)NN)N)NN)NN)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)NN)�r5r6r7�	__slots__rd�classmethodrwr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��__radd__r�r�r��__rmul__r�r�r�r�r�r�r�r�r�r�r�r��	__trunc__�propertyr�r�r�r�r=r�rrrr	rr
rr�dictr�rrrrr!r5r?r@rCrrFr�rHrJr�to_integralrPr�r�rrr�rVrXrSr\r�r�r]rXr`rarEr�rdr�rfr�rgrhrmrrr7rurvrxr{r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r*r*r*r,rs

,
 !@

	
	
	
	
2
4
	



V
7;!$K



f	�>,UnY="c*"	IK23
.*!'rFcCs&t�t�}||_||_||_||_|Sr))rcrdrr;r<rQrR)rCZcoefficientrZspecialr1r*r*r,r:�s
r:c@s$eZdZdd�Zdd�Zdd�ZdS)rOcCs|��|_dSr))rM�new_context)r1r�r*r*r,�__init__sz_ContextManager.__init__cCst�|_t|j�|jSr))r�
saved_contextrr�r�r*r*r,�	__enter__s
z_ContextManager.__enter__cCst|j�dSr))rr�)r1�t�v�tbr*r*r,�__exit__sz_ContextManager.__exit__N)r5r6r7r�r�r�r*r*r*r,rOsrOc	@s�eZdZd�dd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
e
Zd�dd�Zdd�Zdd�Zdd�ZdZd d!�Zd"d#�Zd$d%�Zd�d'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Z d;d<�Z!d=d>�Z"d?d@�Z#dAdB�Z$dCdD�Z%dEdF�Z&dGdH�Z'dIdJ�Z(dKdL�Z)dMdN�Z*dOdP�Z+dQdR�Z,dSdT�Z-dUdV�Z.dWdX�Z/dYdZ�Z0d[d\�Z1d]d^�Z2d_d`�Z3dadb�Z4dcdd�Z5dedf�Z6dgdh�Z7didj�Z8dkdl�Z9dmdn�Z:dodp�Z;dqdr�Z<dsdt�Z=dudv�Z>dwdx�Z?dydz�Z@d{d|�ZAd}d~�ZBdd��ZCd�d��ZDd�d��ZEd�d��ZFd�d�d��ZGd�d��ZHd�d��ZId�d��ZJd�d��ZKd�d��ZLd�d��ZMd�d��ZNd�d��ZOd�d��ZPd�d��ZQd�d��ZRd�d��ZSd�d��ZTd�d��ZUeUZVdS)�rNc
s<zt}
WntyYn0|dur(|n|
j|_|dur<|n|
j|_|durP|n|
j|_|durd|n|
j|_|durx|n|
j|_|dur�|n|
j|_|	dur�g|_n|	|_�dur�|
j	�
�|_	n.t�t�s�t�fdd�t
�D��|_	n�|_	�du�rt�t
d�|_n0t�t��s2t�fdd�t
�D��|_n�|_dS)Nc3s|]}|t|�v�fVqdSr)�rW�r~r��r:r*r,�	<genexpr>Ir.z#Context.__init__.<locals>.<genexpr>r'c3s|]}|t|�v�fVqdSr)r�r��r;r*r,r�Pr.)r�	NameErrorrFrErDrGr�r��_ignored_flagsr:rMrer�r9�fromkeysr;)r1rFrErDrGr�r�r;r:r�Zdcr*)r;r:r,r�0s.

zContext.__init__cCs�t|t�std|��|dkr<||kr�td||||f��nJ|dkrb||kr�td||||f��n$||ksr||kr�td||||f��t�|||�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)rerWrxrrrc�__setattr__)r1�namerzZvminZvmaxr*r*r,�_set_integer_checkTs
zContext._set_integer_checkcCs`t|t�std|��|D]}|tvrtd|��qtD]}||vr8td|��q8t�|||�S)Nz%s must be a signal dictz%s is not a valid signal dict)rer�rxr9�KeyErrorrcr�)r1r�r��keyr*r*r,�_set_signal_dictbs
zContext._set_signal_dictcCs�|dkr|�||dd�S|dkr0|�||dd�S|dkrH|�||dd�S|dkr`|�||dd�S|d	krx|�||dd�S|d
kr�|tvr�td|��t�|||�S|dks�|d
kr�|�||�S|dkr�t�|||�Std|��dS)NrFr/r�rDr�r'rGr�r�rEz%s: invalid rounding moder;r:r�z.'decimal.Context' object has no attribute '%s')r��_rounding_modesrxrcr�r��AttributeError)r1r�rzr*r*r,r�ms*�zContext.__setattr__cCstd|��dS)Nz%s cannot be deleted)r�)r1r�r*r*r,�__delattr__�szContext.__delattr__c	CsNdd�|j��D�}dd�|j��D�}|j|j|j|j|j|j|j	||ffS)NcSsg|]\}}|r|�qSr*r*�r~Zsigr�r*r*r,r��r.z&Context.__reduce__.<locals>.<listcomp>cSsg|]\}}|r|�qSr*r*r�r*r*r,r��r.)
r;�itemsr:r�rFrErDrGr�r�)r1r;r:r*r*r,r��s��zContext.__reduce__cCs|g}|�dt|��dd�|j��D�}|�dd�|�d�dd�|j��D�}|�dd�|�d�d�|�d	S)
NzrContext(prec=%(prec)d, rounding=%(rounding)s, Emin=%(Emin)d, Emax=%(Emax)d, capitals=%(capitals)d, clamp=%(clamp)dcSsg|]\}}|r|j�qSr*�r5)r~r�r�r*r*r,r��r.z$Context.__repr__.<locals>.<listcomp>zflags=[z, �]cSsg|]\}}|r|j�qSr*r�)r~r�r�r*r*r,r��r.ztraps=[�))rs�varsr;r�rtr:)r1r��namesr*r*r,r��s�zContext.__repr__cCs|jD]}d|j|<qdSr�r��r1�flagr*r*r,rN�s
zContext.clear_flagscCs|jD]}d|j|<qdSr�r�r�r*r*r,�clear_traps�s
zContext.clear_trapsc
Cs.t|j|j|j|j|j|j|j|j|j	�	}|Sr))
rrFrErDrGr�r�r;r:r��r1Zncr*r*r,rK�s
�zContext._shallow_copyc
Cs6t|j|j|j|j|j|j|j��|j	��|j
�	}|Sr))rrFrErDrGr�r�r;rMr:r�r�r*r*r,rM�s�zContext.copycGs^t�||�}||jvr*|�j|g|�R�Sd|j|<|j|sR|�j|g|�R�S||��dSre)�_condition_maprIr�r3r;r:)r1Z	conditionZexplanationr+�errorr*r*r,rj�s


zContext._raise_errorcCs
|jt�Sr))�
_ignore_flagsr9r�r*r*r,r��szContext._ignore_all_flagscGs|jt|�|_t|�Sr))r�rp)r1r;r*r*r,r��szContext._ignore_flagscGs8|rt|dttf�r|d}|D]}|j�|�q"dSr�)rerqrpr��remove)r1r;r�r*r*r,�
_regard_flags�szContext._regard_flagscCst|j|jd�Sre)rWrDrFr�r*r*r,r��sz
Context.EtinycCst|j|jd�Sre)rWrGrFr�r*r*r,r��szContext.EtopcCs|j}||_|Sr))rE)r1r�rEr*r*r,rL�szContext._set_roundingrScCsjt|t�r*||��ksd|vr*|�td�St||d�}|��r`t|j�|j	|j
kr`|�td�S|�|�S)NrTzAtrailing or leading whitespace and underscores are not permitted.rLzdiagnostic info too long in NaN)rerfrhrjrrr�rlr<rFr�r�)r1rlr�r*r*r,�create_decimal�s��zContext.create_decimalcCst�|�}|�|�Sr))rrwr�)r1r�r�r*r*r,�create_decimal_from_floats
z!Context.create_decimal_from_floatcCst|dd�}|j|d�SrW)r�r��r1r4r*r*r,rn!szContext.abscCs8t|dd�}|j||d�}|tur0td|��n|SdS�NTr�rL�Unable to convert %s to Decimal)r�r�r�rx�r1r4rr�r*r*r,�add6s
zContext.addcCst|�|��Sr))rfr�r�r*r*r,�_applyKszContext._applycCst|t�std��|��S)Nz,canonical requires a Decimal as an argument.)rerrxrVr�r*r*r,rVNs	
zContext.canonicalcCst|dd�}|j||d�SrW)r�r��r1r4rr*r*r,r�[s!zContext.comparecCst|dd�}|j||d�SrW)r�rXr�r*r*r,rXs zContext.compare_signalcCst|dd�}|�|�Sr�)r�rSr�r*r*r,rS�szContext.compare_totalcCst|dd�}|�|�Sr�)r�r\r�r*r*r,r\�szContext.compare_total_magcCst|dd�}|��Sr�)r�r�r�r*r*r,r��s
zContext.copy_abscCst|dd�}t|�Sr�)r�rr�r*r*r,�copy_decimal�s
zContext.copy_decimalcCst|dd�}|��Sr�)r�r�r�r*r*r,r��s
zContext.copy_negatecCst|dd�}|�|�Sr�)r�r]r�r*r*r,r]�szContext.copy_signcCs8t|dd�}|j||d�}|tur0td|��n|SdSr�)r�r�r�rxr�r*r*r,�divides
zContext.dividecCs8t|dd�}|j||d�}|tur0td|��n|SdSr�)r�r�r�rxr�r*r*r,�
divide_int+s
zContext.divide_intcCs8t|dd�}|j||d�}|tur0td|��n|SdSr�)r�r�r�rxr�r*r*r,r�Bs
zContext.divmodcCst|dd�}|j|d�SrW)r�rXr�r*r*r,rXWszContext.expcCst|dd�}|j|||d�SrW)r�r)r1r4rrNr*r*r,roszContext.fmacCst|t�std��|��S)Nz/is_canonical requires a Decimal as an argument.)rerrxr`r�r*r*r,r`�s	
zContext.is_canonicalcCst|dd�}|��Sr�)r�rar�r*r*r,ra�szContext.is_finitecCst|dd�}|��Sr�)r�rEr�r*r*r,rE�szContext.is_infinitecCst|dd�}|��Sr�)r�r�r�r*r*r,r��s
zContext.is_nancCst|dd�}|j|d�SrW)r�rdr�r*r*r,rd�szContext.is_normalcCst|dd�}|��Sr�)r�r�r�r*r*r,r��szContext.is_qnancCst|dd�}|��Sr�)r�rfr�r*r*r,rf�szContext.is_signedcCst|dd�}|��Sr�)r�r�r�r*r*r,r��s
zContext.is_snancCst|dd�}|j|d�SrW)r�rgr�r*r*r,rgszContext.is_subnormalcCst|dd�}|��Sr�)r�rhr�r*r*r,rh%szContext.is_zerocCst|dd�}|j|d�SrW)r�rrr�r*r*r,rr6sz
Context.lncCst|dd�}|j|d�SrW)r�rur�r*r*r,ruLsz
Context.log10cCst|dd�}|j|d�SrW)r�rvr�r*r*r,rvhszContext.logbcCst|dd�}|j||d�SrW)r�r�r�r*r*r,r��szContext.logical_andcCst|dd�}|j|d�SrW)r�r�r�r*r*r,r��szContext.logical_invertcCst|dd�}|j||d�SrW)r�r�r�r*r*r,r��szContext.logical_orcCst|dd�}|j||d�SrW)r�r�r�r*r*r,r��szContext.logical_xorcCst|dd�}|j||d�SrW)r�r�r�r*r*r,r��szContext.maxcCst|dd�}|j||d�SrW)r�r�r�r*r*r,r�szContext.max_magcCst|dd�}|j||d�SrW)r�r�r�r*r*r,r�szContext.mincCst|dd�}|j||d�SrW)r�r�r�r*r*r,r�-szContext.min_magcCst|dd�}|j|d�SrW)r�r�r�r*r*r,�minus>sz
Context.minuscCs8t|dd�}|j||d�}|tur0td|��n|SdSr�)r�r�r�rxr�r*r*r,�multiplyOs
zContext.multiplycCst|dd�}|j|d�SrW)r�r�r�r*r*r,r�oszContext.next_minuscCst|dd�}|j|d�SrW)r�r�r�r*r*r,r��szContext.next_pluscCst|dd�}|j||d�SrW)r�r�r�r*r*r,r��s zContext.next_towardcCst|dd�}|j|d�SrW)r�rCr�r*r*r,rC�szContext.normalizecCst|dd�}|j|d�SrW)r�r�r�r*r*r,r��s/zContext.number_classcCst|dd�}|j|d�SrW)r�r�r�r*r*r,�plusszContext.pluscCs:t|dd�}|j|||d�}|tur2td|��n|SdSr�)r�r?r�rx)r1r4rrr�r*r*r,�powers
Iz
Context.powercCst|dd�}|j||d�SrW)r�rr�r*r*r,res7zContext.quantizecCstd�Sr�r�r�r*r*r,r��sz
Context.radixcCs8t|dd�}|j||d�}|tur0td|��n|SdSr�)r�r�r�rxr�r*r*r,r��s
zContext.remaindercCst|dd�}|j||d�SrW)r�r�r�r*r*r,r��szContext.remainder_nearcCst|dd�}|j||d�SrW)r�r�r�r*r*r,r��szContext.rotatecCst|dd�}|�|�Sr�)r�rFr�r*r*r,rFszContext.same_quantumcCst|dd�}|j||d�SrW)r�r�r�r*r*r,r�$szContext.scalebcCst|dd�}|j||d�SrW)r�r�r�r*r*r,r�7sz
Context.shiftcCst|dd�}|j|d�SrW)r�rPr�r*r*r,rPUszContext.sqrtcCs8t|dd�}|j||d�}|tur0td|��n|SdSr�)r�r�r�rxr�r*r*r,�subtractus
zContext.subtractcCst|dd�}|j|d�SrW)r�r�r�r*r*r,r��szContext.to_eng_stringcCst|dd�}|j|d�SrW)r�r�r�r*r*r,�
to_sci_string�szContext.to_sci_stringcCst|dd�}|j|d�SrW)r�rJr�r*r*r,rJ�szContext.to_integral_exactcCst|dd�}|j|d�SrW)r�rr�r*r*r,r�szContext.to_integral_value)	NNNNNNNNN)N)rS)N)Wr5r6r7r�r�r�r�r�r�r�rNr�rKrMr�rjr�r�r�r�r�r�rLr�r�rnr�r�rVr�rXrSr\r�r�r�r]r�r�r�rXrr`rarEr�rdr�rfr�rgrhrrrurvr�r�r�r�r�r�r�r�r�r�r�r�r�rCr�r�r�rr�r�r�r�rFr�r�rPr�r�r�rJrr�r*r*r*r,rs��
$



$#


%
 #2
P:&" rc@s"eZdZdZddd�Zdd�ZdS)ro�rCrWrXNcCsf|durd|_d|_d|_nFt|t�rD|j|_t|j�|_|j|_n|d|_|d|_|d|_dS)Nr'r/r_)rCrWrXrerr;r<rQ)r1rzr*r*r,r��s



z_WorkRep.__init__cCsd|j|j|jfS)Nz(%r, %r, %r)r�r�r*r*r,r�sz_WorkRep.__repr__)N)r5r6r7r�r�r�r*r*r*r,ro�s
rocCs�|j|jkr|}|}n|}|}tt|j��}tt|j��}|jtd||d�}||jd|krpd|_||_|jd|j|j9_|j|_||fS)Nr�r_r/r�)rXrlrfrWr�)r�r�rF�tmpr�Ztmp_lenZ	other_lenrXr*r*r,r�sr�cCsb|dkrdS|dkr |d|Stt|��}t|�t|�d��}||krPdS|d|SdS)Nr'r�rS)rfrnrl�rstrip)r9r�Zstr_nZval_nr*r*r,r*(sr*cCsB|dks|dkrtd��d}||kr>||||d?}}q|S)Nr'z3Both arguments to _sqrt_nearest should be positive.r/)rr)r9r4rr*r*r,�
_sqrt_nearest=sr�cCs2d|>||?}}|d||d@|d@|kS)Nr/r_r*)r-r�rr�r*r*r,�_rshift_nearestLsr�cCs&t||�\}}|d||d@|kS)Nr_r/)r�)r4rr�r�r*r*r,�_div_nearestTsr�r$c		Cs�||}d}||kr(t|�||>|ksD||krxt|�||?|krxt||d>|t||t||�|��}|d7}qtdtt|��d|�}t||�}t||�}t|ddd�D]}t||�t|||�}q�t|||�S)Nr'r/���r]r�)rnr�r�r�rWrlrfr)	r-�M�Lr0�R�TZyshift�wr�r*r*r,�_ilog\s"���


r�c
Cs�|d7}tt|��}||||dk}|dkr�d|}|||}|dkrZ|d|9}nt|d|�}t||�}t|�}t|||�}||}	nd}t|d|�}	t|	|d�S�Nr_r/r'r�r()rlrfr�r��
_log10_digits)
rNr�r,rOr�r�r��log_dZlog_10Zlog_tenpowerr*r*r,rt�s 

rtc	Cs�|d7}tt|��}||||dk}|dkrr|||}|dkrR|d|9}nt|d|�}t|d|�}nd}|r�ttt|���d}||dkr�t|t||�d|�}q�d}nd}t||d�Sr)rlrfr�r�rnr)	rNr�r,rOr�r�rr>Z	f_log_tenr*r*r,rp�s"rpc@seZdZdd�Zdd�ZdS)�
_Log10MemoizecCs
d|_dS)NZ/23025850929940456840179914546843642076011014886)r~r�r*r*r,r��sz_Log10Memoize.__init__cCs�|dkrtd��|t|j�kr�d}d||d}tttd||�d��}||d�d|krbql|d7}q"|�d�dd�|_t|jd|d	��S)
Nr'zp should be nonnegativer]r�r_r(rSr�r/)rrrlr~rfr�r�r�rW)r1r,r>r�r~r*r*r,�	getdigits�s	
z_Log10Memoize.getdigitsN)r5r6r7r�rr*r*r*r,r�src	Cs�t||>|�}tdtt|��d|�}t||�}||>}t|ddd�D]}t|||||�}qPt|ddd�D]"}||d>}t||||�}q|||S)Nr�r]r/r'r�r_)r)rWrlrfr�r)	r-r�r�r�r�r0ZMshiftr r�r*r*r,�_iexp�s
rc	Cs�|d7}td|tt|��d�}||}||}|dkrH|d|}n|d|}t|t|��\}}t|d|�}tt|d|�d�||dfS)Nr_r'r/r�i�r])r�rlrfr�rr�r)	rNr�r,r>r�r�ZcshiftZquotr3r*r*r,r^$sr^cCs�ttt|���|}t||||d�}||}|dkrJ||d|}nt||d|�}|dkr�tt|��|dk|dkkr�d|ddd|}	}
q�d|d|}	}
n,t||d|d�\}	}
t|	d�}	|
d7}
|	|
fS)Nr/r'r�)rlrfrnrpr�r^)r.r/r1r2r,rZlxcr�Zpcr�rXr*r*r,r8Hs
r8r(�F�5�(�ri�r�r�)	r��2�3�4�5�6�7�8rDcCs0|dkrtd��t|�}dt|�||dS)Nr'z0The argument to _log10_lb should be nonnegative.r()rrrfrl)rNZ
correctionZstr_cr*r*r,r+rsr+cCsLt|t�r|St|t�r t|�S|r8t|t�r8t�|�S|rHtd|��tS)Nr�)rerrWrvrwrxr�)r�r�Zallow_floatr*r*r,r�}s


r�cCs�t|t�r||fSt|tj�rR|jsDt|jtt|j	�|j
�|j�}|t|j�fS|rrt|tj
�rr|jdkrr|j}t|t�r�t�}|r�d|jt<n|�td�|t�|�fSttfS)Nr'r/rb)rer�_numbersZRationalrRr:r;rfrWr<�denominatorrQ�	numeratorZComplexr�r�rvrr;rrjrwr�)r1r�r�r2r*r*r,r��s(
�
�r�r'i?Bi���)rFrEr:r;rGrDr�r�r`)rFrEr:r;a�        # 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<alt>\#)?
(?P<zeropad>0)?
(?P<minimumwidth>(?!0)\d+)?
(?P<thousands_sep>,)?
(?:\.(?P<precision>0|(?!0)\d+))?
(?P<type>[eEfFgGn%])?
\Z
cCs�t�|�}|durtd|��|��}|d}|d}|ddu|d<|drv|durbtd|��|durvtd|��|p|d|d<|p�d|d<|d	dur�d
|d	<t|dp�d�|d<|d
dur�t|d
�|d
<|d
dkr�|ddus�|ddvr�d|d
<|ddk�rfd|d<|du�r&t��}|ddu�r@td|��|d|d<|d|d<|d|d<n*|ddu�r|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: � �>rCrV�minimumwidthrSr�r'r�ZgGnr/r9r��
thousands_sepzJExplicit thousands separator conflicts with 'n' type in format specifier: �grouping�
decimal_pointrUr]r�)�_parse_format_specifier_regex�matchrr�	groupdictrW�_locale�
localeconv)�format_specr�r{Zformat_dictrrr*r*r,r�sT
��
�r�c	Cs�|d}|d}||t|�t|�}|d}|dkrF|||}nj|dkr\|||}nT|dkrr|||}n>|dkr�t|�d}|d|�||||d�}ntd	��|S)
Nrrr�<r�=�^r_zUnrecognised alignment field)rlrr)	rCr�r�rrZpaddingrr�Zhalfr*r*r,r�ms"r�cCspddlm}m}|sgS|ddkrJt|�dkrJ||dd�||d��S|dtjkrd|dd�Std��dS)Nr')�chain�repeatr�r_r�z unrecognised format for grouping)�	itertoolsr'r(rlr!�CHAR_MAXrr)rr'r(r*r*r,�_group_lengths�s
r+cCs�|d}|d}g}t|�D]�}|dkr0td��ttt|�|d�|�}|�d|t|�||d��|d|�}||8}|s�|dkr�q�|t|�8}qtt|�|d�}|�d|t|�||d��|�t|��S)Nrrr'zgroup length should be positiver/rS)r+rrr�r�rlrsrt�reversed)r~r��	min_width�sepr�groupsrOr*r*r,�_insert_thousands_sep�s $$r0cCs$|rdS|ddvr|dSdSdS)NrVrCz +rUr*)�is_negativer�r*r*r,r��s
r�cCs�t||�}|s|dr"|d|}|dks6|ddvr\ddddd�|d}|d	�||�7}|dd
krp|d
7}|dr�|dt|�t|�}nd}t|||�}t||||�S)
NZaltrr'r�r�r�r�)r�r�r�r�z{0}{1:+}r�rr)r��formatrlr0r�)r1r|r}rXr�rCZecharr-r*r*r,r��s
r�ZInfz-Infr�r�r_)N)F)r')r$)r$)FF)F)N)r/)y�__all__r5Z	__xname__�__version__Z__libmpdec_version__Zmathr�Znumbersr�sys�collectionsr(Z_namedtupler�ImportErrorrrrrrrrrr$r%�maxsizer r!r"r#�ArithmeticErrorrrr	r�ZeroDivisionErrorr
rrrrrr
rrrxrr9r�r�ZcontextvarsZ
ContextVarrHrrrrcrr:�Number�registerrOrror�rWr�r)r*r�r�r�r�rtrprrrrr^r8r+r�r�rrr�re�compile�VERBOSE�
IGNORECASErrgrr�DOTALLrZlocaler!r�r�r+r0r�r�rornr>rZr6rYrA�	hash_info�modulusr�r�r�r�r�r�r�r*r*r*r,�<module>ss`#

&
���

.
^

0",#
%$+
�

*���
�
�
P
%
)

?>