Hacked By AnonymousFox

Current Path : /opt/alt/python35/lib64/python3.5/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/__pycache__/_pydecimal.cpython-35.opt-2.pyc



���]}�*@s�dddddddddd	d
ddd
ddddddddddddddddddd d!d"d#g$ZeZd$Zd%Zd&Zd'd(lZd'd(lZd'd(l	Z	y#d'd)l
mZedd*�Z
Wnek
r�d+d,�Z
YnXdZdZdZdZdZdZdZdZd-Ze	jd.d/d0krUd1Zd1Zd1Znd2Zd2Zd2Zeed0ZGd3d�de�ZGd4d�de�ZGd5d�de�Z Gd6d�de �Z!Gd7d	�d	ee"�Z#Gd8d�de �Z$Gd9d�de e"�Z%Gd:d
�d
e�Z&Gd;d�de �Z'Gd<d�de�Z(Gd=d�de�Z)Gd>d
�d
e&e(�Z*Gd?d�de&e(e)�Z+Gd@d�dee,�Z-ee#e&e*e(e+e e)e-g	Z.e!e e$e e%e e'e iZ/eeeeeeeefZ0yd'd(l1Z1Wn4ek
r_GdAdB�dBe2�Z3e3�Z1[3YnXye1j4WnKe5k
r�e6e1j7�dC�r�e1j7�`8dDd�Z9dEd�Z:YnFXe1j4�Z4e6e4dC�r�e4`8e4dFd�Z:e4dGd�Z9[1[4d(dHd�Z;GdId�de2�Z<dJdKdL�Z=ej>j?e<�GdMdN�dNe2�Z@GdOd�de2�ZAGdPdQ�dQe2�ZBd'dRdS�ZCeDjEZFdTdU�ZGdVdW�ZHdXdY�ZIdZd[�ZJd\d]d^�ZKd_d`�ZLdadb�ZMGdcdd�dde2�ZNeN�jOZPd\dedf�ZQdgdh�ZRdidj�ZSdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|i	d}d~�ZTdJdJdd��ZUdJd�d��ZVeAd�d�d�ed�e#e*e gd�gd�d�d�d�d�d0d�d'�ZWeAd�d�d�ed�e#e*e ee+gd�g�ZXeAd�d�d�ed�gd�g�ZYd'd(lZZZeZj[d�eZj\eZj]B�j^Z_eZj[d��j^Z`eZj[d��j^ZaeZj[d�eZj\eZjbB�Zc[Zyd'd(ldZeWnek
r�YnXd(d�d��Zfd�d��Zgd�d��Zhd0d�d��Zid�d��Zjd�d��Zke<d��Zle<d��Zme<d��Zne<d'�Zoe<d0�Zpe<d0�ZqelemfZre	jsjtZue	jsjvZwe	jsjxZyezdzeud.eu�Z{[	d(S)��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_THREADSZdecimalz1.70z2.4.1�N)�
namedtuplezsign digits exponentcGs|S)N�)�argsr'r'�//opt/alt/python35/lib64/python3.5/_pydecimal.py�<lambda>�sr*T��?�l��N�Zoi@�Tc@seZdZdd�ZdS)rcGsdS)Nr')�self�contextr(r'r'r)�handle�szDecimalException.handleN)�__name__�
__module__�__qualname__r0r'r'r'r)r�sc@seZdZdS)rN)r1r2r3r'r'r'r)r�s
c@seZdZdd�ZdS)r	cGs:|r6t|dj|djdd�}|j|�StS)Nr%�nT)�_dec_from_triple�_sign�_int�_fix_nan�_NaN)r.r/r(�ansr'r'r)r0�s#
zInvalidOperation.handleN)r1r2r3r0r'r'r'r)r	�sc@seZdZdd�ZdS)rcGstS)N)r9)r.r/r(r'r'r)r0szConversionSyntax.handleN)r1r2r3r0r'r'r'r)r�sc@seZdZdd�ZdS)r
cGst|S)N)�_SignedInfinity)r.r/�signr(r'r'r)r0szDivisionByZero.handleN)r1r2r3r0r'r'r'r)r
s
c@seZdZdd�ZdS)rcGstS)N)r9)r.r/r(r'r'r)r0szDivisionImpossible.handleN)r1r2r3r0r'r'r'r)rsc@seZdZdd�ZdS)rcGstS)N)r9)r.r/r(r'r'r)r0)szDivisionUndefined.handleN)r1r2r3r0r'r'r'r)r!sc@seZdZdS)rN)r1r2r3r'r'r'r)r,s
c@seZdZdd�ZdS)rcGstS)N)r9)r.r/r(r'r'r)r0CszInvalidContext.handleN)r1r2r3r0r'r'r'r)r8sc@seZdZdS)rN)r1r2r3r'r'r'r)rFs
c@seZdZdS)r
N)r1r2r3r'r'r'r)r
Rs	c@seZdZdd�ZdS)rcGs�|jttttfkr#t|S|dkrk|jtkrFt|St|d|j|j	|jd�S|dkr�|jt
kr�t|St|d|j|j	|jd�SdS)Nr%�9r-)�roundingrrrrr;rr5�prec�Emaxr)r.r/r<r(r'r'r)r0sszOverflow.handleN)r1r2r3r0r'r'r'r)r]sc@seZdZdS)rN)r1r2r3r'r'r'r)r�s
c@seZdZdS)rN)r1r2r3r'r'r'r)r�s
c@seZdZedd�ZdS)�
MockThreadingcCs|jtS)N)�modules�	__xname__)r.�sysr'r'r)�local�szMockThreading.localN)r1r2r3rDrEr'r'r'r)rA�srA�__decimal_context__cCs>|tttfkr+|j�}|j�|tj�_dS)N)rrr�copy�clear_flags�	threading�current_threadrF)r/r'r'r)r�s
cCsFytj�jSWn.tk
rAt�}|tj�_|SYnXdS)N)rIrJrF�AttributeErrorr)r/r'r'r)r�s
	cCs:y|jSWn(tk
r5t�}||_|SYnXdS)N)rFrKr)�_localr/r'r'r)r�s
		cCs8|tttfkr+|j�}|j�||_dS)N)rrrrGrHrF)r/rLr'r'r)r�s
cCs|dkrt�}t|�S)N)r�_ContextManager)�ctxr'r'r)r�s$	c@s�eZdZd�Zdddd�Zed	d
��Zdd�Zd
d�Zdddd�Z	dd�Z
dd�Zdd�Zddd�Z
ddd�Zddd�Zddd�Zddd �Zdd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)dd*d+�Zdd,d-�Zdd.d/�Zdd0d1�Zd2dd3d4�Zdd5d6�ZeZdd7d8�Zdd9d:�Zdd;d<�ZeZ dd=d>�Z!d?d@�Z"ddAdB�Z#ddCdD�Z$ddEdF�Z%ddGdH�Z&ddIdJ�Z'ddKdL�Z(ddMdN�Z)ddOdP�Z*dQdR�Z+dSdT�Z,e,Z-dUdV�Z.e/e.�Z.dWdX�Z0e/e0�Z0dYdZ�Z1d[d\�Z2d]d^�Z3d_d`�Z4dadb�Z5dcdd�Z6dedf�Z7dgdh�Z8didj�Z9dkdl�Z:dmdn�Z;dodp�Z<e=dqe5dre6dse7dte8due9dve:dwe;dxe<�Z>ddydz�Z?d{d|�Z@d}d~�ZAddd��ZBdd�d��ZCd�d��ZDddd�d��ZEdd�d��ZFdd�d��ZGddd�d��ZHdd�d��ZId�d��ZJd�d��ZKddd�d��ZLddd�d��ZMeMZNdd�d��ZOdd�d��ZPdd�d��ZQd�d��ZRd�d��ZSd�d��ZTd�d��ZUdd�d��ZVdd�d��ZWdd�d��ZXd�d��ZYd�d��ZZdd�d��Z[dd�d��Z\d�d��Z]d�d��Z^d�d��Z_d�d��Z`dd�d��Zad�d��Zbd�d��Zcd�d��Zddd�d��Zed�d��Zfd�d��Zgdd�d��Zhd�d��Zidd�d��Zjdd�d��Zkd�d��Zld�d��Zmdd�d��Zndd�d��Zodd�d��Zpdd�d��Zqdd�d��Zrdd�d��Zsdd�d��Ztdd�d��Zudd�d��Zvdd�d��Zwd�d��Zxdd�d��Zydd�d��Zzdd�d��Z{d�d��Z|d�d��Z}d�d��Z~ddd�d��ZdS)�r�_expr7r6�_is_special�0NcCs�tj|�}t|t�r�t|j��}|dkre|dkrQt�}|jtd|�S|j	d�dkr�d|_
n	d|_
|j	d�}|dk	r|j	d�p�d}t|j	d	�p�d
�}tt||��|_|t
|�|_d|_n�|j	d�}|dk	rxtt|p<d
��jd
�|_|j	d
�rld|_q�d|_nd
|_d|_d|_|St|t�r�|dkr�d|_
n	d|_
d|_tt|��|_d|_|St|t�r5|j|_|j
|_
|j|_|j|_|St|t�r�|j|_
t|j�|_t|j�|_d|_|St|ttf�r:t
|�dkr�td��t|dt�o�|ddks�td��|d|_
|ddkr"d
|_|d|_d|_ng}	xk|dD]_}
t|
t�r�d|
ko_dknr�|	sv|
dkr�|	j|
�q3td��q3W|ddkr�djtt|	��|_|d|_d|_n\t|dt�r*djtt|	pdg��|_|d|_d|_ntd��|St|t�r�|dkr^t�}|jtd�tj|�}|j|_|j
|_
|j|_|j|_|Std|��dS)NzInvalid literal for Decimal: %rr<�-r-r%�intZfrac��exprQF�diag�signal�Nr4�FT�ztInvalid tuple size in creation of Decimal from list or tuple.  The list or tuple should have exactly three elements.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.r+�	zTThe second value in the tuple must be composed of integers in the range 0 through 9.zUThe third value in the tuple must be an integer, or one of the strings 'F', 'n', 'N'.z;strict semantics for mixing floats and Decimals are enabledzCannot convert %r to Decimal)r%r-)r4rX) �object�__new__�
isinstance�str�_parser�stripr�_raise_errorr�groupr6rSr7�lenrOrP�lstrip�absr�_WorkRepr<rU�list�tuple�
ValueError�append�join�map�floatr�
from_float�	TypeError)�cls�valuer/r.�m�intpart�fracpartrUrV�digitsZdigitr'r'r)r]4s�			$							#
	
+
$
		zDecimal.__new__cCs�t|t�r||�St|t�s4td��tj|�sRtj|�rb|t|��Stjd|�dkr�d}nd}t	|�j
�\}}|j�d}t|t
|d|�|�}|tkr�|S||�SdS)Nzargument must be int or float.g�?r%r-�)r^rSrnrp�_math�isinf�isnan�repr�copysignrf�as_integer_ratio�
bit_lengthr5r_r)rq�fr<r4�d�k�resultr'r'r)ro�s
	!zDecimal.from_floatcCs6|jr2|j}|dkr"dS|dkr2dSdS)Nr4r-rXr+r%)rPrO)r.rUr'r'r)�_isnan�s		zDecimal._isnancCs$|jdkr |jrdSdSdS)NrYr-r%���)rOr6)r.r'r'r)�_isinfinitys
	zDecimal._isinfinitycCs�|j�}|dkr!d}n|j�}|s9|r�|dkrNt�}|dkrm|jtd|�S|dkr�|jtd|�S|r�|j|�S|j|�SdS)NFr+�sNaNr%)r�rrbr	r8)r.�otherr/�self_is_nan�other_is_nanr'r'r)�_check_nanss"
		

zDecimal._check_nanscCs�|dkrt�}|js'|jr�|j�rF|jtd|�S|j�re|jtd|�S|j�r�|jtd|�S|j�r�|jtd|�SdS)Nzcomparison involving sNaNzcomparison involving NaNr%)rrP�is_snanrbr	�is_qnan)r.r�r/r'r'r)�_compare_check_nans.s(					zDecimal._compare_check_nanscCs|jp|jdkS)NrQ)rPr7)r.r'r'r)�__bool__OszDecimal.__bool__cCs^|js|jrN|j�}|j�}||kr:dS||krJdSdS|sj|s^dSd|jS|s{d|jS|j|jkr�dS|j|jkr�dS|j�}|j�}||kr7|jd|j|j}|jd|j|j}||krdS||kr)d|jSd	|jSn#||krNd
|jSd|jSdS)Nr%r-rQr�r�r�r�r�r�r�r�)rPr�r6�adjustedr7rO)r.r�Zself_infZ	other_inf�
self_adjustedZother_adjusted�self_paddedZother_paddedr'r'r)�_cmpVs>zDecimal._cmpcCsTt||dd�\}}|tkr+|S|j||�rAdS|j|�dkS)N�equality_opTFr%)�_convert_for_comparison�NotImplementedr�r�)r.r�r/r'r'r)�__eq__�szDecimal.__eq__cCsTt||�\}}|tkr%|S|j||�}|rAdS|j|�dkS)NFr%)r�r�r�r�)r.r�r/r:r'r'r)�__lt__�szDecimal.__lt__cCsTt||�\}}|tkr%|S|j||�}|rAdS|j|�dkS)NFr%)r�r�r�r�)r.r�r/r:r'r'r)�__le__�szDecimal.__le__cCsTt||�\}}|tkr%|S|j||�}|rAdS|j|�dkS)NFr%)r�r�r�r�)r.r�r/r:r'r'r)�__gt__�szDecimal.__gt__cCsTt||�\}}|tkr%|S|j||�}|rAdS|j|�dkS)NFr%)r�r�r�r�)r.r�r/r:r'r'r)�__ge__�szDecimal.__ge__cCsYt|dd�}|js*|rF|jrF|j||�}|rF|St|j|��S)N�raiseitT)�_convert_otherrPr�rr�)r.r�r/r:r'r'r)�compare�szDecimal.comparecCs�|jrF|j�r$td��n"|j�r4tS|jrBtStS|jdkrmtd|jt	�}ntt
|jt	�}t|j�|t	}|dkr�|n|}|dkr�dS|S)Nz"Cannot hash a signaling NaN value.r%�
r-r+r����)
rPr�rp�is_nan�_PyHASH_NANr6�_PyHASH_INFrO�pow�_PyHASH_MODULUS�
_PyHASH_10INVrSr7)r.Zexp_hashZhash_r:r'r'r)�__hash__�s		zDecimal.__hash__cCs(t|jttt|j��|j�S)N)rr6rirmrSr7rO)r.r'r'r)�as_tuple�szDecimal.as_tuplecCsdt|�S)Nz
Decimal('%s'))r_)r.r'r'r)�__repr__�szDecimal.__repr__Fc	Cs�ddg|j}|jr`|jdkr3|dS|jdkrQ|d|jS|d|jS|jt|j�}|jdkr�|dkr�|}nE|s�d
}n6|jdkr�|d
dd
}n|d
dd
}|dkr
d}d
d||j}nf|t|j�krF|jd|t|j�}d}n*|jd|�}d
|j|d�}||kr�d}n4|dkr�t�}ddg|jd||}||||S)NrTrRrYZInfinityr4�NaNr�r%�r-rQrZ�.�e�Ez%+di����)r6rPrOr7rdr�capitals)	r.�engr/r<�
leftdigits�dotplacertrurUr'r'r)�__str__�s:						zDecimal.__str__cCs|jddd|�S)Nr�Tr/)r�)r.r/r'r'r)�
to_eng_string.szDecimal.to_eng_stringcCsx|jr%|jd|�}|r%|S|dkr:t�}|r_|jtkr_|j�}n|j�}|j|�S)Nr/)rPr�rr>r�copy_abs�copy_negate�_fix)r.r/r:r'r'r)�__neg__7s		zDecimal.__neg__cCsx|jr%|jd|�}|r%|S|dkr:t�}|r_|jtkr_|j�}nt|�}|j|�S)Nr/)rPr�rr>rr�rr�)r.r/r:r'r'r)�__pos__Ms		zDecimal.__pos__TcCsi|s|j�S|jr5|jd|�}|r5|S|jrS|jd|�}n|jd|�}|S)Nr/)r�rPr�r6r�r�)r.�roundr/r:r'r'r)�__abs__bs
		zDecimal.__abs__c
Csbt|�}|tkr|S|dkr1t�}|jsC|jr�|j||�}|r_|S|j�r�|j|jkr�|j�r�|jtd�St	|�S|j�r�t	|�St
|j|j�}d}|jt
kr�|j|jkr�d}|rO|rOt
|j|j�}|r*d}t|d|�}|j|�}|S|s�t||j|jd�}|j||j�}|j|�}|S|s�t||j|jd�}|j||j�}|j|�}|St|�}t|�}t|||j�\}}t�}	|j|jkr�|j|jkrjt|d|�}|j|�}|S|j|jkr�||}}|jdkr�d|	_|j|j|_|_q�d|	_n6|jdkr�d|	_d\|_|_n	d|	_|jdkr$|j|j|	_n|j|j|	_|j|	_t	|	�}|j|�}|S)Nz
-INF + INFr%r-rQ)r%r%)r�r�rrPr�r�r6rbr	r�minrOr>rr5r��maxr?�_rescalerg�
_normalizer<rSrU)
r.r�r/r:rUZnegativezeror<�op1�op2r�r'r'r)�__add__xs|	

!	
			zDecimal.__add__cCsft|�}|tkr|S|js.|jrM|j|d|�}|rM|S|j|j�d|�S)Nr/)r�r�rPr�r�r�)r.r�r/r:r'r'r)�__sub__�szDecimal.__sub__cCs/t|�}|tkr|S|j|d|�S)Nr/)r�r�r�)r.r�r/r'r'r)�__rsub__�szDecimal.__rsub__cCs�t|�}|tkr|S|dkr1t�}|j|jA}|jsS|jr�|j||�}|ro|S|j�r�|s�|jtd�St	|S|j�r�|s�|jtd�St	|S|j
|j
}|s�|rt|d|�}|j|�}|S|j
dkr=t||j
|�}|j|�}|S|j
dkrtt||j
|�}|j|�}|St|�}t|�}t|t|j|j�|�}|j|�}|S)Nz(+-)INF * 0z0 * (+-)INFrQ�1)r�r�rr6rPr�r�rbr	r;rOr5r�r7rgr_rS)r.r�r/Z
resultsignr:Z	resultexpr�r�r'r'r)�__mul__�sH	"zDecimal.__mul__cCsct|�}|tkrtS|dkr1t�}|j|jA}|jsS|jr�|j||�}|ro|S|j�r�|j�r�|jtd�S|j�r�t	|S|j�r�|jt
d�t|d|j��S|s|s�|jt
d�S|jtd|�S|s+|j|j}d}nt|j�t|j�|jd}|j|j|}t|�}t|�}	|dkr�t|jd||	j�\}}
n$t|j|	jd|�\}}
|
r�|d	dkr>|d7}nG|j|j}x4||kr=|ddkr=|d}|d7}q
Wt|t|�|�}|j|�S)
Nz(+-)INF/(+-)INFzDivision by infinityrQz0 / 0zx / 0r%r-r�rw)r�r�rr6rPr�r�rbr	r;rr5�Etinyrr
rOrdr7r?rg�divmodrSr_r�)r.r�r/r<r:rU�coeff�shiftr�r��	remainder�	ideal_expr'r'r)�__truediv__sP		'&$

zDecimal.__truediv__cCs�|j|jA}|j�r(|j}nt|j|j�}|j�|j�}|sr|j�sr|dkr�t|dd�|j||j�fS||jkrlt	|�}t	|�}|j
|j
kr�|jd|j
|j
9_n|jd|j
|j
9_t|j|j�\}}	|d|jkrlt|t
|�d�t|jt
|	�|�fS|jtd�}
|
|
fS)Nr+rQr%r�z%quotient too large in //, % or divmodr�)r6r�rOr�r�r5r�r>r?rgrUrSr�r_rbr)r.r�r/r<r��expdiffr�r��q�rr:r'r'r)�_divideZs* 		zDecimal._dividecCs/t|�}|tkr|S|j|d|�S)Nr/)r�r�r�)r.r�r/r'r'r)�__rtruediv__{szDecimal.__rtruediv__cCs/t|�}|tkr|S|dkr1t�}|j||�}|rS||fS|j|jA}|j�r�|j�r�|jtd�}||fSt||jtd�fS|s�|s�|jt	d�}||fS|jt
d|�|jtd�fS|j||�\}}|j|�}||fS)Nzdivmod(INF, INF)zINF % xzdivmod(0, 0)zx // 0zx % 0)
r�r�rr�r6r�rbr	r;rr
r�r�)r.r�r/r:r<Zquotientr�r'r'r)�
__divmod__�s0	


zDecimal.__divmod__cCs/t|�}|tkr|S|j|d|�S)Nr/)r�r�r�)r.r�r/r'r'r)�__rdivmod__�szDecimal.__rdivmod__cCs�t|�}|tkr|S|dkr1t�}|j||�}|rM|S|j�ri|jtd�S|s�|r�|jtd�S|jtd�S|j||�d}|j	|�}|S)NzINF % xzx % 0z0 % 0r-)
r�r�rr�r�rbr	rr�r�)r.r�r/r:r�r'r'r)�__mod__�s"	zDecimal.__mod__cCs/t|�}|tkr|S|j|d|�S)Nr/)r�r�r�)r.r�r/r'r'r)�__rmod__�szDecimal.__rmod__cCsp|dkrt�}t|dd�}|j||�}|rC|S|j�r_|jtd�S|s�|r{|jtd�S|jtd�S|j�r�t|�}|j|�St	|j
|j
�}|s�t|jd|�}|j|�S|j
�|j
�}||jdkr#|jt�S|dkrQ|j||j�}|j|�St|�}t|�}|j|jkr�|jd	|j|j9_n|jd	|j|j9_t|j|j�\}}	d|	|d@|jkr|	|j8}	|d7}|d	|jkr%|jt�S|j}
|	d
krKd|
}
|	}	t|
t|	�|�}|j|�S)Nr�Tzremainder_near(infinity, x)zremainder_near(x, 0)zremainder_near(0, 0)rQr-r+r�r%r�)rr�r�r�rbr	rrr�r�rOr5r6r�r?rr�r>rgrUrSr�r_)r.r�r/r:�ideal_exponentr�r�r�r�r�r<r'r'r)�remainder_near�sZ				



 


	
zDecimal.remainder_nearcCs�t|�}|tkr|S|dkr1t�}|j||�}|rM|S|j�r�|j�ru|jtd�St|j|jAS|s�|r�|jt	d|j|jA�S|jt
d�S|j||�dS)Nz
INF // INFzx // 0z0 // 0r%)r�r�rr�r�rbr	r;r6r
rr�)r.r�r/r:r'r'r)�__floordiv__s$	zDecimal.__floordiv__cCs/t|�}|tkr|S|j|d|�S)Nr/)r�r�r�)r.r�r/r'r'r)�
__rfloordiv__6szDecimal.__rfloordiv__cCsR|j�r<|j�r$td��|jr3dnd}nt|�}t|�S)Nz%Cannot convert signaling NaN to floatz-nan�nan)r�r�rjr6r_rn)r.�sr'r'r)�	__float__=szDecimal.__float__cCs�|jr<|j�r$td��n|j�r<td��d|j}|jdkrt|t|j�d|jS|t|jd|j�p�d�SdS)NzCannot convert NaN to integerz"Cannot convert infinity to integerr-r%r�rQr�)	rPr�rjr��
OverflowErrorr6rOrSr7)r.r�r'r'r)�__int__Gs	
zDecimal.__int__cCs|S)Nr')r.r'r'r)�realVszDecimal.realcCs
td�S)Nr%)r)r.r'r'r)�imagZszDecimal.imagcCs|S)Nr')r.r'r'r)�	conjugate^szDecimal.conjugatecCstt|��S)N)�complexrn)r.r'r'r)�__complex__aszDecimal.__complex__cCsq|j}|j|j}t|�|krg|t|�|d�jd�}t|j||jd�St|�S)NrQT)	r7r?�clamprdrer5r6rOr)r.r/ZpayloadZmax_payload_lenr'r'r)r8ds	#zDecimal._fix_nancCs|jr,|j�r"|j|�St|�S|j�}|j�}|s�|j|g|j}tt	|j
|�|�}||j
kr�|jt�t
|jd|�St|�St|j�|j
|j}||kr|jtd|j�}|jt�|jt�|S||k}|r+|}|j
|kr�t|j�|j
|}	|	dkrt
|jd|d�}d}	|j|j}
|
||	�}|jd|	�p�d}|dkrtt|�d�}t|�|jkr|dd�}|d7}||kr/|jtd|j�}nt
|j||�}|r]|r]|jt�|rp|jt�|r�|jt�|jt�|s�|jt�|S|r�|jt�|jdkr|j
|kr|jt�|jd|j
|}
t
|j|
|�St|�S)NrQz
above Emaxr%r�r-r�)rPr�r8rr��Etopr@r�r�r�rOrbrr5r6rdr7r?rrr�_pick_rounding_functionr>r_rSrr
)r.r/r�r��exp_maxZnew_expZexp_minr:Zself_is_subnormalrvZrounding_method�changedr�r�r'r'r)r�psn
	













zDecimal._fixcCst|j|�rdSdSdS)Nr%r-r�)�
_all_zerosr7)r.r?r'r'r)�_round_down�szDecimal._round_downcCs|j|�S)N)r�)r.r?r'r'r)�	_round_up�szDecimal._round_upcCs5|j|dkrdSt|j|�r-dSdSdS)NZ56789r-r%r�)r7r�)r.r?r'r'r)�_round_half_up�s
zDecimal._round_half_upcCs't|j|�rdS|j|�SdS)Nr-r�)�_exact_halfr7r�)r.r?r'r'r)�_round_half_down�szDecimal._round_half_downcCsJt|j|�r9|dks5|j|ddkr9dS|j|�SdS)Nr%r-�02468r�)r�r7r�)r.r?r'r'r)�_round_half_even�s#zDecimal._round_half_evencCs(|jr|j|�S|j|�SdS)N)r6r�)r.r?r'r'r)�_round_ceiling�s	
zDecimal._round_ceilingcCs(|js|j|�S|j|�SdS)N)r6r�)r.r?r'r'r)�_round_floors	
zDecimal._round_floorcCs<|r*|j|ddkr*|j|�S|j|�SdS)Nr-Z05)r7r�)r.r?r'r'r)�_round_05ups
zDecimal._round_05uprrrrrrrrcCs�|dk	rGt|t�s'td��tdd|�}|j|�S|jrw|j�rktd��ntd��t|j	dt
��S)Nz+Second argument to round should be integralr%r�zcannot round a NaNzcannot round an infinity)r^rSrpr5�quantizerPr�rjr�r�r)r.r4rUr'r'r)�	__round__s/
	zDecimal.__round__cCsF|jr0|j�r$td��ntd��t|jdt��S)Nzcannot round a NaNzcannot round an infinityr%)rPr�rjr�rSr�r)r.r'r'r)�	__floor__Ws
	zDecimal.__floor__cCsF|jr0|j�r$td��ntd��t|jdt��S)Nzcannot round a NaNzcannot round an infinityr%)rPr�rjr�rSr�r)r.r'r'r)�__ceil__fs
	zDecimal.__ceil__cCs�t|dd�}t|dd�}|js6|jr7|dkrKt�}|jdkrm|jtd|�S|jdkr�|jtd|�S|jdkr�|}qy|jdkr�|}qy|jdkr�|s�|jtd�St|j|jA}qy|jdkry|s |jtd�St|j|jA}nBt|j|jAt	t
|j�t
|j��|j|j�}|j||�S)	Nr�TrXr�r4rYzINF * 0 in fmaz0 * INF in fma)
r�rPrrOrbr	r;r6r5r_rSr7r�)r.r�Zthirdr/�productr'r'r)�fmaus6					zDecimal.fmacCs�t|�}|tkr|St|�}|tkr8|S|dkrMt�}|j�}|j�}|j�}|s�|s�|r|dkr�|jtd|�S|dkr�|jtd|�S|dkr�|jtd|�S|r�|j|�S|r|j|�S|j|�S|j�o4|j�o4|j�sG|jtd�S|dkrc|jtd�S|sy|jtd�S|j�|j	kr�|jtd�S|r�|r�|jtd�S|j
�r�d}n	|j}tt
|��}t|j��}t|j��}	|j
|td	|j|�|}x)t|	j�D]}
t|d	|�}qDWt||	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�rbr	r8�
_isintegerr�r?�_isevenr6rfrSrg�to_integral_valuer�rU�ranger5r_)r.r��modulor/r�r�Z
modulo_is_nanr<�base�exponent�ir'r'r)�
_power_modulo�sl	


							$zDecimal._power_modulocCs9t|�}|j|j}}x(|ddkrI|d}|d7}q"Wt|�}|j|j}}x(|ddkr�|d}|d7}qlW|dkrs||9}x(|ddkr�|d}|d7}q�W|dkr�dS|d|}	|jdkr	|	}	|j�rQ|jdkrQ|jt|�}
t|	|
|d�}nd}tddd||	|�S|jdkrv|d}|dkrF||@|kr�dSt	|�d}
|d
d}|t
t|��kr�dSt|
||�}
t|||�}|
dks%|dkr)dS|
|kr9dSd|
}n�|dkr=t	|�d
d}
t
d|
|�\}}|r�dSx(|ddkr�|d}|
d8}
q�W|dd}|t
t|��kr�dSt|
||�}
t|||�}|
dks|dkr dS|
|kr0dSd|
}ndS|d|krUdS|
|}tdt|�|�S|dkr�|d|d}}n|dkr�t
tt||���|kr�dSt	|�}|dkrt
tt|�|��|krdS|d|}}x<|d|dko@dknr\|d}|d}q!Wx<|d|dkodknr�|d}|d}q`W|dkrk|dkr�||kr�dSt
||�\}}|dkr�dSdt	|�|>}xGt
|||d�\}}||kr/Pq||d||}qW||ko^|dksedS|}|dkr�||dt|�kr�dS||}||9}|d|kr�dSt|�}|j�r|jdkr|jt|�}
t||
|t
|��}nd}td|d|||�S)Nr�r%r-r�rQr+�r���]�Arw�rZ�d)r+rr�r)rgrSrUr<r�r6rOr�r5�_nbitsrdr_�_decimal_lshift_exactr�rf�	_log10_lb)r.r��p�x�xc�xe�y�yc�yerr�ZzerosZ
last_digitr�Zemaxr�rsr4Zxc_bits�rem�ar�r�Zstr_xcr'r'r)�_power_exact�s�:







//'
'
&

 zDecimal._power_exactcCs�|dk	r|j|||�St|�}|tkr;|S|dkrPt�}|j||�}|rl|S|s�|s�|jtd�StSd}|jdkr�|j	�r�|j
�s�d}n|r�|jtd�S|j�}|s|jdkr	t|dd�St
|S|j�rD|jdkr4t
|St|dd�S|tkr|j	�r�|jdkrtd}n'||jkr�|j}nt|�}|j|}|d|jkr�d|j}|jt�n'|jt�|jt�d|j}t|dd||�S|j�}|j�rc|jdk|dkkr[t|dd�St
|Sd}d}	|j�|j�}
|dk|jdkkr�|
tt|j��krt|d|jd�}n;|j�}|
tt|��krt|d|d�}|dkrm|j||jd�}|dk	rm|dkrgtd|j|j�}d}	|dkrN|j}t|�}
|
j|
j}}t|�}|j|j}}|jdkr�|}d	}xWt||||||�\}}|d
dtt|��|dr(P|d	7}q�Wt|t|�|�}|	r�|j	�r�t|j�|jkr�|jdt|j�}t|j|jd||j|�}|j �}|j!�xt"D]}d|j#|<q�W|j$|�}|jt�|j%t&r$|jt'�|j%t(rG|jt(d|j�xIt't&ttt)fD] }|j%|r]|j|�q]Wn|j$|�}|S)
Nz0 ** 0r%r-z+x ** y with x negative and y not an integerrQr�FTrZrwr�z
above Emax)*rr�r�rr�rbr	�_Oner6r�r�r�r5r;r�r?rSrOrrr��_log10_exp_boundrdr_r@r�rr7rgrUr<�_dpowerrGrH�_signals�trapsr��flagsr
rrr)r.r�r�r/r:Zresult_signZ
multiplierrUZself_adj�exactZboundr�rr
rrrrr�extrar�r�Z
newcontext�	exceptionr'r'r)�__pow__�s�				




	"&






zDecimal.__pow__cCs/t|�}|tkr|S|j|d|�S)Nr/)r�r�r)r.r�r/r'r'r)�__rpow__�	szDecimal.__rpow__cCs|dkrt�}|jr:|jd|�}|r:|S|j|�}|j�rY|S|srt|jdd�S|j|j�g|j	}t
|j�}|j}x;|j|ddkr�||kr�|d7}|d8}q�Wt|j|jd|�|�S)Nr/rQr%r-)
rrPr�r�r�r5r6r@r�r�rdr7rO)r.r/r:�dupr��endrUr'r'r)�	normalize�	s$			&
zDecimal.normalizecCsAt|dd�}|dkr't�}|dkr<|j}|jsN|jr�|j||�}|rj|S|j�s�|j�r�|j�r�|j�r�t|�S|jtd�S|j	�|j
ko�|jkns�|jtd�S|st|j
d|j
�}|j|�S|j�}||jkrB|jtd�S||j
d|jkrl|jtd�S|j|j
|�}|j�|jkr�|jtd�St|j�|jkr�|jtd�S|r�|j�|jkr�|jt�|j
|j
kr.||kr!|jt�|jt�|j|�}|S)	Nr�Tzquantize with one INFz)target exponent out of bounds in quantizerQz9exponent of quantize result too large for current contextr-z7quantize result has too many digits for current context)r�rr>rPr�r�rrbr	r�rOr@r5r6r�r�r?r�rdr7�Eminr
rr)r.rUr>r/r:r�r'r'r)r��	sT		
	(	
				


zDecimal.quantizecCsbt|dd�}|js$|jrR|j�r<|j�pQ|j�oQ|j�S|j|jkS)Nr�T)r�rPr��is_infiniterO)r.r�r/r'r'r)�same_quantum
s
	zDecimal.same_quantumcCs|jrt|�S|s,t|jd|�S|j|kr`t|j|jd|j||�St|j�|j|}|dkr�t|jd|d�}d}|j|}|||�}|jd|�p�d}|dkr�tt	|�d�}t|j||�S)NrQr%r�r-)
rPrr5r6rOr7rdr�r_rS)r.rUr>rvZ
this_functionr�r�r'r'r)r�'
s"	
	
zDecimal._rescalecCs�|dkrtd��|js(|r2t|�S|j|j�d||�}|j�|j�kr�|j|j�d||�}|S)Nr%z'argument should be at least 1 in _roundr-)rjrPrr�r�)r.�placesr>r:r'r'r)�_roundI
s

  zDecimal._roundcCs�|jr/|jd|�}|r%|St|�S|jdkrHt|�S|sat|jdd�S|dkrvt�}|dkr�|j}|jd|�}||kr�|j	t
�|j	t�|S)Nr/r%rQ)rPr�rrOr5r6rr>r�rbrr)r.r>r/r:r'r'r)�to_integral_exact`
s$
	

		

zDecimal.to_integral_exactcCs�|dkrt�}|dkr*|j}|jrY|jd|�}|rO|St|�S|jdkrrt|�S|jd|�SdS)Nr/r%)rr>rPr�rrOr�)r.r>r/r:r'r'r)r�}
s			

zDecimal.to_integral_valuecCsv|dkrt�}|jr_|jd|�}|r:|S|j�r_|jdkr_t|�S|s�t|jd|jd�}|j|�S|jdkr�|j	t
d�S|jd}t|�}|j
d?}|j
d@r|jd}t|j�d?d}n |j}t|j�dd?}||}|dkrT|d|9}d	}	n!t|d|�\}}
|
}	||8}d|}x,||}||kr�Pq�||d?}q�W|	o�|||k}	|	r
|dkr�|d|}n|d|9}||7}n|d
dkr'|d7}tdt|�|�}|j�}|jt�}
|j|�}|
|_|S)Nr/r%rQr+r-zsqrt(-x), x > 0r�rTrw)rrPr�r�r6rr5rOr�rbr	r?rgrUrSrdr7r�r_�
_shallow_copy�
_set_roundingrr>)r.r/r:r?�opr��c�lr�rr�r4r�r>r'r'r)�sqrt�
s`		





	
	




	zDecimal.sqrtcCs	t|dd�}|dkr't�}|js9|jr�|j�}|j�}|s]|r�|dkr�|dkr�|j|�S|dkr�|dkr�|j|�S|j||�S|j|�}|dkr�|j|�}|dkr�|}n|}|j|�S)Nr�Tr-r%r�)r�rrPr�r�r�r��
compare_total)r.r�r/�sn�onr-r:r'r'r)r��
s&	

		zDecimal.maxcCs	t|dd�}|dkr't�}|js9|jr�|j�}|j�}|s]|r�|dkr�|dkr�|j|�S|dkr�|dkr�|j|�S|j||�S|j|�}|dkr�|j|�}|dkr�|}n|}|j|�S)Nr�Tr-r%r�)r�rrPr�r�r�r�r0)r.r�r/r1r2r-r:r'r'r)r�s&	

	zDecimal.mincCsJ|jr
dS|jdkr dS|j|jd�}|dt|�kS)NFr%TrQ)rPrOr7rd)r.�restr'r'r)r�?s	zDecimal._isintegercCs2|s|jdkrdS|jd|jdkS)Nr%Tr-r�r�)rOr7)r.r'r'r)r�HszDecimal._isevencCs9y|jt|j�dSWntk
r4dSYnXdS)Nr-r%)rOrdr7rp)r.r'r'r)r�Ns
zDecimal.adjustedcCs|S)Nr')r.r'r'r)�	canonicalVszDecimal.canonicalcCsAt|dd�}|j||�}|r.|S|j|d|�S)Nr�Tr/)r�r�r�)r.r�r/r:r'r'r)�compare_signal^s
zDecimal.compare_signalcCs�t|dd�}|jr)|jr)tS|jr@|jr@tS|j}|j�}|j�}|sm|rj||kr�t|j�|jf}t|j�|jf}||kr�|r�tStS||kr�|r�tStStS|r*|dkr�tS|dkrtS|dkrtS|dkrjtSn@|dkr:tS|dkrJtS|dkrZtS|dkrjtS||krztS||kr�tS|j|jkr�|r�tStS|j|jkr�|r�tStStS)Nr�Tr-r+)	r�r6�_NegativeOnerr�rdr7�_ZerorO)r.r�r/r<Zself_nanZ	other_nanZself_keyZ	other_keyr'r'r)r0jsf	zDecimal.compare_totalcCs7t|dd�}|j�}|j�}|j|�S)Nr�T)r�r�r0)r.r�r/r��or'r'r)�compare_total_mag�szDecimal.compare_total_magcCstd|j|j|j�S)Nr%)r5r7rOrP)r.r'r'r)r��szDecimal.copy_abscCsE|jr%td|j|j|j�Std|j|j|j�SdS)Nr%r-)r6r5r7rOrP)r.r'r'r)r��s	zDecimal.copy_negatecCs1t|dd�}t|j|j|j|j�S)Nr�T)r�r5r6r7rOrP)r.r�r/r'r'r)�	copy_sign�szDecimal.copy_signcCs�|dkrt�}|jd|�}|r1|S|j�d
krGtS|sQtS|j�dkrmt|�S|j}|j�}|jdkr�|t	t
|jdd��kr�tdd|jd�}n�|jdkr%|t	t
|j
�dd��kr%tdd|j
�d�}n+|jdkrg||krgtddd|dd|�}n�|jdkr�||dkr�tdd|d|d�}n�t|�}|j|j}}|jdkr�|}d}xQt||||�\}	}
|	dd	t	t
|	��|dr*P|d7}q�Wtdt
|	�|
�}|j�}|jt�}|j|�}||_|S)Nr/r-r%rZr�rQr=rwr�r�)rr�r�r7rrr?r�r6rdr_r@r5r�rgrSrUr<�_dexpr*r+rr�r>)r.r/r:r�adjr,r-r�rr�rUr>r'r'r)rU�sJ	
	26& "&	zDecimal.expcCsdS)NTr')r.r'r'r)�is_canonicalszDecimal.is_canonicalcCs|jS)N)rP)r.r'r'r)�	is_finite"szDecimal.is_finitecCs
|jdkS)NrY)rO)r.r'r'r)r%*szDecimal.is_infinitecCs
|jdkS)Nr4rX)r4rX)rO)r.r'r'r)r�.szDecimal.is_nancCs<|js|rdS|dkr)t�}|j|j�kS)NF)rPrr$r�)r.r/r'r'r)�	is_normal2s
	zDecimal.is_normalcCs
|jdkS)Nr4)rO)r.r'r'r)r�:szDecimal.is_qnancCs
|jdkS)Nr-)r6)r.r'r'r)�	is_signed>szDecimal.is_signedcCs
|jdkS)NrX)rO)r.r'r'r)r�BszDecimal.is_snancCs<|js|rdS|dkr)t�}|j�|jkS)NF)rPrr�r$)r.r/r'r'r)�is_subnormalFs
	zDecimal.is_subnormalcCs|jo|jdkS)NrQ)rPr7)r.r'r'r)�is_zeroNszDecimal.is_zerocCs�|jt|j�d}|dkrBtt|dd��dS|dkrnttd|dd��dSt|�}|j|j}}|dkr�t|d|�}t|�}t|�t|�||kS|ttd||��dS)Nr-�r�r+r%r�r�)rOrdr7r_rgrSrU)r.r<r,r-r��num�denr'r'r)�
_ln_exp_boundRs zDecimal._ln_exp_boundc
Csn|dkrt�}|jd|�}|r1|S|s;tS|j�dkrQtS|tkratS|jdkr�|jt	d�St
|�}|j|j}}|j
}||j�d}xMt|||�}|ddttt|���|dr�P|d7}q�Wtt|dk�tt|��|�}|j�}|jt�}	|j|�}|	|_|S)	Nr/r-zln of a negative valuer+rwr�rZr%)rr��_NegativeInfinityr��	_Infinityrr7r6rbr	rgrSrUr?rF�_dlogrdr_rfr5r*r+rr�r>)
r.r/r:r,r-r�rr'r�r>r'r'r)�lnks:			,+	z
Decimal.lncCs|jt|j�d}|dkr:tt|��dS|dkr^ttd|��dSt|�}|j|j}}|dkr�t|d|�}td|�}t|�t|�||kdStd||�}t|�||dkdS)	Nr-r+r%r���Z231r�r�)rOrdr7r_rgrSrU)r.r<r,r-r�rDrEr'r'r)r�s"zDecimal._log10_exp_boundc
Cs�|dkrt�}|jd|�}|r1|S|s;tS|j�dkrQtS|jdkrp|jtd�S|jddkr�|jdd�dt	|j�dkr�t
|jt	|j�d�}n�t|�}|j
|j}}|j}||j�d}xMt|||�}|dd	t	tt|���|drNP|d
7}qWtt
|dk�tt|��|�}|j�}|jt�}	|j|�}|	|_|S)Nr/r-zlog10 of a negative valuer%r�rQr+rwr�rZ)rr�rGr�rHr6rbr	r7rdrrOrgrSrUr?r�_dlog10r_rfr5r*r+rr�r>)
r.r/r:r,r-r�rr'r�r>r'r'r)�log10�s:		=#	,+	z
Decimal.log10cCsy|jd|�}|r|S|dkr1t�}|j�rAtS|sZ|jtdd�St|j��}|j|�S)Nr/zlogb(0)r-)	r�rr�rHrbr
rr�r�)r.r/r:r'r'r)�logb�s		zDecimal.logbcCsJ|jdks|jdkr"dSx!|jD]}|dkr,dSq,WdS)Nr%FZ01T)r6rOr7)r.�digr'r'r)�
_islogical
szDecimal._islogicalcCs�|jt|�}|dkr0d||}n |dkrP||jd�}|jt|�}|dkr�d||}n |dkr�||jd�}||fS)Nr%rQ)r?rd)r.r/�opa�opbZdifr'r'r)�
_fill_logical
szDecimal._fill_logicalcCs�|dkrt�}t|dd�}|j�sA|j�rN|jt�S|j||j|j�\}}djdd�t||�D��}t	d|j
d�p�dd�S)Nr�TrTcSs2g|](\}}tt|�t|�@��qSr')r_rS)�.0r�br'r'r)�
<listcomp>5
s	z'Decimal.logical_and.<locals>.<listcomp>r%rQ)rr�rPrbr	rSr7rl�zipr5re)r.r�r/rQrRr�r'r'r)�logical_and'
s	
!%zDecimal.logical_andcCs8|dkrt�}|jtdd|jd�|�S)Nr%r�)r�logical_xorr5r?)r.r/r'r'r)�logical_invert8
s	zDecimal.logical_invertcCs�|dkrt�}t|dd�}|j�sA|j�rN|jt�S|j||j|j�\}}djdd�t||�D��}t	d|j
d�p�dd�S)Nr�TrTcSs2g|](\}}tt|�t|�B��qSr')r_rS)rTrrUr'r'r)rVM
s	z&Decimal.logical_or.<locals>.<listcomp>r%rQ)rr�rPrbr	rSr7rlrWr5re)r.r�r/rQrRr�r'r'r)�
logical_or?
s	
!%zDecimal.logical_orcCs�|dkrt�}t|dd�}|j�sA|j�rN|jt�S|j||j|j�\}}djdd�t||�D��}t	d|j
d�p�dd�S)Nr�TrTcSs2g|](\}}tt|�t|�A��qSr')r_rS)rTrrUr'r'r)rV^
s	z'Decimal.logical_xor.<locals>.<listcomp>r%rQ)rr�rPrbr	rSr7rlrWr5re)r.r�r/rQrRr�r'r'r)rYP
s	
!%zDecimal.logical_xorcCst|dd�}|dkr't�}|js9|jr�|j�}|j�}|s]|r�|dkr�|dkr�|j|�S|dkr�|dkr�|j|�S|j||�S|j�j|j��}|dkr�|j|�}|dkr|}n|}|j|�S)Nr�Tr-r%r�)	r�rrPr�r�r�r�r�r0)r.r�r/r1r2r-r:r'r'r)�max_maga
s&	

	zDecimal.max_magcCst|dd�}|dkr't�}|js9|jr�|j�}|j�}|s]|r�|dkr�|dkr�|j|�S|dkr�|dkr�|j|�S|j||�S|j�j|j��}|dkr�|j|�}|dkr|}n|}|j|�S)Nr�Tr-r%r�)	r�rrPr�r�r�r�r�r0)r.r�r/r1r2r-r:r'r'r)�min_mag
s&	

	zDecimal.min_magcCs�|dkrt�}|jd|�}|r1|S|j�dkrGtS|j�dkrvtdd|j|j��S|j�}|jt	�|j
�|j|�}||kr�|S|jtdd|j
�d�|�S)Nr/r-r%r=r�r�)rr�r�rGr5r?r�rGr+r�_ignore_all_flagsr�r�r�)r.r/r:�new_selfr'r'r)�
next_minus�
s"	

zDecimal.next_minuscCs�|dkrt�}|jd|�}|r1|S|j�dkrGtS|j�dkrvtdd|j|j��S|j�}|jt	�|j
�|j|�}||kr�|S|jtdd|j
�d�|�S)Nr/r-r=r%r�r�)rr�r�rHr5r?r�rGr+rr^r�r�r�)r.r/r:r_r'r'r)�	next_plus�
s"	

zDecimal.next_pluscCs7t|dd�}|dkr't�}|j||�}|rC|S|j|�}|dkrk|j|�S|dkr�|j|�}n|j|�}|j�r�|jt	d|j
�|jt�|jt�n\|j
�|jkr3|jt�|jt�|jt�|jt�|s3|jt�|S)Nr�Tr%r-z Infinite result from next_towardr�)r�rr�r�r:rar`r�rbrr6rrr�r$rr
r)r.r�r/r:Z
comparisonr'r'r)�next_toward�
s4		
	






zDecimal.next_towardcCs�|j�rdS|j�r dS|j�}|dkr<dS|d
krLdS|j�ri|jredSdS|dkr~t�}|jd|�r�|jr�d	Sd
S|jr�dSdSdS)Nr�r�r-z	+Infinityz	-Infinityz-Zeroz+Zeror/z
-Subnormalz
+Subnormalz-Normalz+Normalr�)r�r�r�rBr6rrA)r.r/�infr'r'r)�number_class�
s,				zDecimal.number_classcCs
td�S)Nr�)r)r.r'r'r)�radix#sz
Decimal.radixcCsP|dkrt�}t|dd�}|j||�}|rC|S|jdkr_|jt�S|jt|�ko�|jkns�|jt�S|j�r�t	|�St|�}|j
}|jt|�}|dkr�d||}n|dkr
||d�}||d�|d|�}t|j
|jd�pFd|j�S)Nr�Tr%rQ)rr�r�rOrbr	r?rSr�rr7rdr5r6re)r.r�r/r:�torot�rotdig�topadZrotatedr'r'r)�rotate's,	
)

		zDecimal.rotatecCs|dkrt�}t|dd�}|j||�}|rC|S|jdkr_|jt�Sd|j|j}d|j|j}|t|�ko�|kns�|jt�S|j	�r�t
|�St|j|j
|jt|��}|j|�}|S)Nr�Tr%r+r�)rr�r�rOrbr	r@r?rSr�rr5r6r7r�)r.r�r/r:ZliminfZlimsupr�r'r'r)�scalebHs"	
"

%zDecimal.scalebcCss|dkrt�}t|dd�}|j||�}|rC|S|jdkr_|jt�S|jt|�ko�|jkns�|jt�S|j�r�t	|�St|�}|j
}|jt|�}|dkr�d||}n|dkr
||d�}|dkr,|d|�}n"|d|}||jd�}t|j
|jd�pid|j�S)Nr�Tr%rQ)rr�r�rOrbr	r?rSr�rr7rdr5r6re)r.r�r/r:rfrgrhZshiftedr'r'r)r�as2	
)

		z
Decimal.shiftcCs|jt|�ffS)N)�	__class__r_)r.r'r'r)�
__reduce__�szDecimal.__reduce__cCs)t|�tkr|S|jt|��S)N)�typerrkr_)r.r'r'r)�__copy__�szDecimal.__copy__cCs)t|�tkr|S|jt|��S)N)rmrrkr_)r.�memor'r'r)�__deepcopy__�szDecimal.__deepcopy__cCs|dkrt�}t|d|�}|jr~t|j|�}t|j��}|ddkrn|d7}t|||�S|ddkr�ddg|j|d<|ddkr�t	|j|j
|jd�}|j}|d}|dk	ry|ddkr|j
|d	|�}n]|dd
krB|j||�}n7|ddkryt|j
�|kry|j
||�}|r�|jdkr�|dd
kr�|jd|�}|jt|j
�}	|ddkr|r�|dk	r�d	|}
qSd	}
nS|dd
kr|	}
n:|ddkrS|jdkrM|	dkrM|	}
nd	}
|
dkrzd}d|
|j
}nh|
t|j
�kr�|j
d|
t|j
�}d}n,|j
d|
�p�d}|j
|
d�}|	|
}
t|j|||
|�S)N�_localeconvrm�%�g�Gr+�	precision�eEr-zfF%ZgGr%r�rQrTi����)r�_parse_format_specifierrP�_format_signr6r_r��
_format_alignr�r5r7rOr>r(r�rd�_format_number)r.Z	specifierr/rq�specr<�bodyr>rur�r�rtrurUr'r'r)�
__format__�sZ		
	
%&
				
zDecimal.__format__)rOr7r6rP)�r1r2r3�	__slots__r]�classmethodror�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__r��propertyr�r�r�r8r�r�r�r�r�r�r�r�r��dictr�r�r�r�r�rrrr r#r�r&r�r(r)r��to_integralr/r�r�r�r�r�r4r5r0r9r�r�r:rUr=r>r%r�r?r�r@r�rArBrFrJrrMrNrPrSrXrZr[rYr\r]r`rarbrdrerirjr�rlrnrpr}r'r'r'r)r+s�(
 !@				4	V7;!$K

f		>,U��="c*"	IK23
.*!'FcCs7tjt�}||_||_||_||_|S)N)r\r]rr6r7rOrP)r<ZcoefficientrZspecialr.r'r'r)r5�s				r5c@s4eZdZdd�Zdd�Zdd�ZdS)rMcCs|j�|_dS)N)rG�new_context)r.r�r'r'r)�__init__sz_ContextManager.__init__cCs t�|_t|j�|jS)N)r�
saved_contextrr�)r.r'r'r)�	__enter__	s
z_ContextManager.__enter__cCst|j�dS)N)rr�)r.�t�v�tbr'r'r)�__exit__
sz_ContextManager.__exit__N)r1r2r3r�r�r�r'r'r'r)rMsrMc@seZdZddddddddddd�	Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
e
Zddd�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��ZFdd�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�y
t}
Wntk
rYnX|dk	r1|n|
j|_|dk	rO|n|
j|_|dk	rm|n|
j|_|dk	r�|n|
j|_|dk	r�|n|
j|_|dk	r�|n|
j|_|	dkr�g|_n	|	|_�dkr|
j	j
�|_	nAt�t�sMt�fdd�t
�D��|_	n	�|_	�dkrztjt
d�|_nAt�t�s�t�fdd�t
�D��|_n	�|_dS)Nc3s'|]}|t|�k�fVqdS)N)rS)rTr�)rr'r)�	<genexpr><sz#Context.__init__.<locals>.<genexpr>r%c3s'|]}|t|�k�fVqdS)N)rS)rTr�)rr'r)r�Cs)r�	NameErrorr?r>r$r@r�r��_ignored_flagsrrGr^r�r�fromkeysr)r.r?r>r$r@r�r�rrr�Zdcr')rrr)r�#s.

	)	)zContext.__init__cCs�t|t�std|��|dkrV||kr�td||||f��nk|dkr�||kr�td||||f��n4||ks�||kr�td||||f��tj|||�S)Nz%s must be an integerz-infz%s must be in [%s, %d]. got: %srcz%s must be in [%d, %s]. got: %sz%s must be in [%d, %d]. got %s)r^rSrprjr\�__setattr__)r.�namerrZvminZvmaxr'r'r)�_set_integer_checkGszContext._set_integer_checkcCs�t|t�std|��x*|D]"}|tkr&td|��q&Wx*tD]"}||krStd|��qSWtj|||�S)Nz%s must be a signal dictz%s is not a valid signal dict)r^r�rpr�KeyErrorr\r�)r.r�r��keyr'r'r)�_set_signal_dictUs

zContext._set_signal_dictcCs@|dkr"|j||dd�S|dkrD|j||dd�S|dkrf|j||dd�S|dkr�|j||dd�S|d	kr�|j||dd�S|d
kr�|tkr�td|��tj|||�S|dks�|d
kr
|j||�S|dkr,tj|||�Std|��dS)Nr?r-rcr$z-infr%r@r�r�r>z%s: invalid rounding moderrr�z.'decimal.Context' object has no attribute '%s')r��_rounding_modesrpr\r�r�rK)r.r�rrr'r'r)r�`s(zContext.__setattr__cCstd|��dS)Nz%s cannot be deleted)rK)r.r�r'r'r)�__delattr__yszContext.__delattr__c	Csodd�|jj�D�}dd�|jj�D�}|j|j|j|j|j|j|j	||ffS)NcSs"g|]\}}|r|�qSr'r')rT�sigr�r'r'r)rV~s	z&Context.__reduce__.<locals>.<listcomp>cSs"g|]\}}|r|�qSr'r')rTr�r�r'r'r)rVs	)
r�itemsrrkr?r>r$r@r�r�)r.rrr'r'r)rl}s
zContext.__reduce__cCs�g}|jdt|��dd�|jj�D�}|jddj|�d�dd�|jj�D�}|jddj|�d�dj|�d	S)
NzrContext(prec=%(prec)d, rounding=%(rounding)s, Emin=%(Emin)d, Emax=%(Emax)d, capitals=%(capitals)d, clamp=%(clamp)dcSs%g|]\}}|r|j�qSr')r1)rTrr�r'r'r)rV�s	z$Context.__repr__.<locals>.<listcomp>zflags=[z, �]cSs%g|]\}}|r|j�qSr')r1)rTr�r�r'r'r)rV�s	ztraps=[�))rk�varsrr�rlr)r.r��namesr'r'r)r��s	zContext.__repr__cCs%x|jD]}d|j|<q
WdS)Nr%)r)r.�flagr'r'r)rH�szContext.clear_flagscCs%x|jD]}d|j|<q
WdS)Nr%)r)r.r�r'r'r)�clear_traps�szContext.clear_trapsc
CsCt|j|j|j|j|j|j|j|j|j	�	}|S)N)
rr?r>r$r@r�r�rrr�)r.�ncr'r'r)r*�szContext._shallow_copyc
CsOt|j|j|j|j|j|j|jj�|j	j�|j
�	}|S)N)rr?r>r$r@r�r�rrGrr�)r.r�r'r'r)rG�s
zContext.copycGsqtj||�}||jkr4|�j||�Sd|j|<|j|sa|�j||�S||��dS)Nr-)�_condition_map�getr�r0rr)r.Z	conditionZexplanationr(�errorr'r'r)rb�s

zContext._raise_errorcCs
|jt�S)N)�
_ignore_flagsr)r.r'r'r)r^�szContext._ignore_all_flagscGs |jt|�|_t|�S)N)r�rh)r.rr'r'r)r��szContext._ignore_flagscGsN|r)t|dttf�r)|d}x|D]}|jj|�q0WdS)Nr%)r^rirhr��remove)r.rr�r'r'r)�
_regard_flags�s

zContext._regard_flagscCst|j|jd�S)Nr-)rSr$r?)r.r'r'r)r��sz
Context.EtinycCst|j|jd�S)Nr-)rSr@r?)r.r'r'r)r��szContext.EtopcCs|j}||_|S)N)r>)r.rmr>r'r'r)r+�s		zContext._set_roundingrQcCs�t|t�r1||j�kr1|jtd�St|d|�}|j�r~t|j�|j	|j
kr~|jtd�S|j|�S)Nz/no trailing or leading whitespace is permitted.r/zdiagnostic info too long in NaN)r^r_rarbrrr�rdr7r?r�r�)r.rDr�r'r'r)�create_decimal�s!	+	zContext.create_decimalcCstj|�}|j|�S)N)rror�)r.rr�r'r'r)�create_decimal_from_floatsz!Context.create_decimal_from_floatcCs"t|dd�}|jd|�S)Nr�Tr/)r�r�)r.rr'r'r)rfszContext.abscCsNt|dd�}|j|d|�}|tkrFtd|��n|SdS)Nr�Tr/zUnable to convert %s to Decimal)r�r�r�rp)r.rrUr�r'r'r)�add)s
zContext.addcCst|j|��S)N)r_r�)r.rr'r'r)�_apply>szContext._applycCs%t|t�std��|j�S)Nz,canonical requires a Decimal as an argument.)r^rrpr4)r.rr'r'r)r4As	zContext.canonicalcCs%t|dd�}|j|d|�S)Nr�Tr/)r�r�)r.rrUr'r'r)r�Ns!zContext.comparecCs%t|dd�}|j|d|�S)Nr�Tr/)r�r5)r.rrUr'r'r)r5rs zContext.compare_signalcCst|dd�}|j|�S)Nr�T)r�r0)r.rrUr'r'r)r0�szContext.compare_totalcCst|dd�}|j|�S)Nr�T)r�r9)r.rrUr'r'r)r9�szContext.compare_total_magcCst|dd�}|j�S)Nr�T)r�r�)r.rr'r'r)r��s
zContext.copy_abscCst|dd�}t|�S)Nr�T)r�r)r.rr'r'r)�copy_decimal�s
zContext.copy_decimalcCst|dd�}|j�S)Nr�T)r�r�)r.rr'r'r)r��s
zContext.copy_negatecCst|dd�}|j|�S)Nr�T)r�r:)r.rrUr'r'r)r:�szContext.copy_signcCsNt|dd�}|j|d|�}|tkrFtd|��n|SdS)Nr�Tr/zUnable to convert %s to Decimal)r�r�r�rp)r.rrUr�r'r'r)�divide�s
zContext.dividecCsNt|dd�}|j|d|�}|tkrFtd|��n|SdS)Nr�Tr/zUnable to convert %s to Decimal)r�r�r�rp)r.rrUr�r'r'r)�
divide_ints
zContext.divide_intcCsNt|dd�}|j|d|�}|tkrFtd|��n|SdS)Nr�Tr/zUnable to convert %s to Decimal)r�r�r�rp)r.rrUr�r'r'r)r�5s
zContext.divmodcCs"t|dd�}|jd|�S)Nr�Tr/)r�rU)r.rr'r'r)rUJszContext.expcCs(t|dd�}|j||d|�S)Nr�Tr/)r�r�)r.rrUr-r'r'r)r�bszContext.fmacCs%t|t�std��|j�S)Nz/is_canonical requires a Decimal as an argument.)r^rrpr=)r.rr'r'r)r=ys	zContext.is_canonicalcCst|dd�}|j�S)Nr�T)r�r>)r.rr'r'r)r>�szContext.is_finitecCst|dd�}|j�S)Nr�T)r�r%)r.rr'r'r)r%�szContext.is_infinitecCst|dd�}|j�S)Nr�T)r�r�)r.rr'r'r)r��s
zContext.is_nancCs"t|dd�}|jd|�S)Nr�Tr/)r�r?)r.rr'r'r)r?�szContext.is_normalcCst|dd�}|j�S)Nr�T)r�r�)r.rr'r'r)r��szContext.is_qnancCst|dd�}|j�S)Nr�T)r�r@)r.rr'r'r)r@�szContext.is_signedcCst|dd�}|j�S)Nr�T)r�r�)r.rr'r'r)r��s
zContext.is_snancCs"t|dd�}|jd|�S)Nr�Tr/)r�rA)r.rr'r'r)rAszContext.is_subnormalcCst|dd�}|j�S)Nr�T)r�rB)r.rr'r'r)rBszContext.is_zerocCs"t|dd�}|jd|�S)Nr�Tr/)r�rJ)r.rr'r'r)rJ)sz
Context.lncCs"t|dd�}|jd|�S)Nr�Tr/)r�rM)r.rr'r'r)rM?sz
Context.log10cCs"t|dd�}|jd|�S)Nr�Tr/)r�rN)r.rr'r'r)rN[szContext.logbcCs%t|dd�}|j|d|�S)Nr�Tr/)r�rX)r.rrUr'r'r)rXuszContext.logical_andcCs"t|dd�}|jd|�S)Nr�Tr/)r�rZ)r.rr'r'r)rZ�szContext.logical_invertcCs%t|dd�}|j|d|�S)Nr�Tr/)r�r[)r.rrUr'r'r)r[�szContext.logical_orcCs%t|dd�}|j|d|�S)Nr�Tr/)r�rY)r.rrUr'r'r)rY�szContext.logical_xorcCs%t|dd�}|j|d|�S)Nr�Tr/)r�r�)r.rrUr'r'r)r��szContext.maxcCs%t|dd�}|j|d|�S)Nr�Tr/)r�r\)r.rrUr'r'r)r\�szContext.max_magcCs%t|dd�}|j|d|�S)Nr�Tr/)r�r�)r.rrUr'r'r)r�szContext.mincCs%t|dd�}|j|d|�S)Nr�Tr/)r�r])r.rrUr'r'r)r] szContext.min_magcCs"t|dd�}|jd|�S)Nr�Tr/)r�r�)r.rr'r'r)�minus1sz
Context.minuscCsNt|dd�}|j|d|�}|tkrFtd|��n|SdS)Nr�Tr/zUnable to convert %s to Decimal)r�r�r�rp)r.rrUr�r'r'r)�multiplyBs
zContext.multiplycCs"t|dd�}|jd|�S)Nr�Tr/)r�r`)r.rr'r'r)r`bszContext.next_minuscCs"t|dd�}|jd|�S)Nr�Tr/)r�ra)r.rr'r'r)ravszContext.next_pluscCs%t|dd�}|j|d|�S)Nr�Tr/)r�rb)r.rrUr'r'r)rb�s zContext.next_towardcCs"t|dd�}|jd|�S)Nr�Tr/)r�r#)r.rr'r'r)r#�szContext.normalizecCs"t|dd�}|jd|�S)Nr�Tr/)r�rd)r.rr'r'r)rd�s/zContext.number_classcCs"t|dd�}|jd|�S)Nr�Tr/)r�r�)r.rr'r'r)�plus�szContext.pluscCsQt|dd�}|j||d|�}|tkrItd|��n|SdS)Nr�Tr/zUnable to convert %s to Decimal)r�rr�rp)r.rrUr�r�r'r'r)�powers
Iz
Context.powercCs%t|dd�}|j|d|�S)Nr�Tr/)r�r�)r.rrUr'r'r)r�Xs7zContext.quantizecCs
td�S)Nr�)r)r.r'r'r)re�sz
Context.radixcCsNt|dd�}|j|d|�}|tkrFtd|��n|SdS)Nr�Tr/zUnable to convert %s to Decimal)r�r�r�rp)r.rrUr�r'r'r)r��s
zContext.remaindercCs%t|dd�}|j|d|�S)Nr�Tr/)r�r�)r.rrUr'r'r)r��szContext.remainder_nearcCs%t|dd�}|j|d|�S)Nr�Tr/)r�ri)r.rrUr'r'r)ri�szContext.rotatecCst|dd�}|j|�S)Nr�T)r�r&)r.rrUr'r'r)r&�szContext.same_quantumcCs%t|dd�}|j|d|�S)Nr�Tr/)r�rj)r.rrUr'r'r)rjszContext.scalebcCs%t|dd�}|j|d|�S)Nr�Tr/)r�r�)r.rrUr'r'r)r�*sz
Context.shiftcCs"t|dd�}|jd|�S)Nr�Tr/)r�r/)r.rr'r'r)r/HszContext.sqrtcCsNt|dd�}|j|d|�}|tkrFtd|��n|SdS)Nr�Tr/zUnable to convert %s to Decimal)r�r�r�rp)r.rrUr�r'r'r)�subtracths
zContext.subtractcCs"t|dd�}|jd|�S)Nr�Tr/)r�r�)r.rr'r'r)r�szContext.to_eng_stringcCs"t|dd�}|jd|�S)Nr�Tr/)r�r�)r.rr'r'r)�
to_sci_string�szContext.to_sci_stringcCs"t|dd�}|jd|�S)Nr�Tr/)r�r))r.rr'r'r)r)�szContext.to_integral_exactcCs"t|dd�}|jd|�S)Nr�Tr/)r�r�)r.rr'r'r)r��szContext.to_integral_value)Wr1r2r3r�r�r�r�r�rlr�rHr�r*rGrnrbr^r�r�r�r�r�r+r�r�rfr�r�r4r�r5r0r9r�r�r�r:r�r�r�rUr�r=r>r%r�r?r�r@r�rArBrJrMrNrXrZr[rYr�r\r�r]r�r�r`rarbr#rdr�r�r�rer�r�rir&rjr�r/r�r�r�r)r�r�r'r'r'r)rs�"

$#


%
 #2P:&" c@s7eZdZd	Zddd�Zdd�ZeZdS)
rgr<rSrUNcCs�|dkr*d|_d|_d|_nct|t�rf|j|_t|j�|_|j|_n'|d|_|d|_|d|_dS)Nr%r-r+)r<rSrUr^rr6r7rO)r.rrr'r'r)r��s		

z_WorkRep.__init__cCsd|j|j|jfS)Nz(%r, %r, %r))r<rSrU)r.r'r'r)r��sz_WorkRep.__repr__)r<rSrU)r1r2r3r~r�r�r�r'r'r'r)rg�srgcCs�|j|jkr!|}|}n|}|}tt|j��}tt|j��}|jtd||d�}||jd|kr�d|_||_|jd|j|j9_|j|_||fS)Nr-r+r�r�)rUrdr_rSr�)r�r�r?�tmpr�Ztmp_lenZ	other_lenrUr'r'r)r��s			r�cCs{|dkrdS|dkr(|d|Stt|��}t|�t|jd��}||krjdS|d|SdS)Nr%r�rQ)r_rfrd�rstrip)r4r�Zstr_nZval_nr'r'r)r
sr
cCs[|dks|dkr$td��d}x*||krV||||d?}}q-W|S)Nr%z3Both arguments to _sqrt_nearest should be positive.r-)rj)r4rrUr'r'r)�
_sqrt_nearest2sr�cCs7d|>||?}}|d||d@|d@|kS)Nr-r+r')r
r�rUr�r'r'r)�_rshift_nearestAsr�cCs/t||�\}}|d||d@|kS)Nr+r-)r�)rrUr�r�r'r'r)�_div_nearestIsr�rc		Cs7||}d}x�||kr9t|�||>|ks_||kr�t|�||?|kr�t||d>|t||t||�|��}|d7}qWtdtt|��d|�}t||�}t||�}x>t|ddd�D]&}t||�t|||�}q�Wt|||�S)Nr%r-r�rZi����r�)rfr�r�r�rSrdr_r�)	r
�M�Lr�R�TZyshift�wr�r'r'r)�_ilogQs
)&'%$r�c
Cs�|d7}tt|��}||||dk}|dkr�d|}|||}|dkru|d|9}nt|d|�}t||�}t|�}t|||�}||}	nd}t|d|�}	t|	|d�S)Nr+r-r%r�r)rdr_r�r��
_log10_digits)
r-r�rr.rr�r��log_dZlog_10Zlog_tenpowerr'r'r)rL�s 


rLc	Cs|d7}tt|��}||||dk}|dkr�|||}|dkrk|d|9}nt|d|�}t|d|�}nd}|r�ttt|���d}||dkr�t|t||�d|�}qd}nd}t||d�S)Nr+r-r%r�r)rdr_r�r�rfr�)	r-r�rr.rr�r�rZ	f_log_tenr'r'r)rI�s"
$	rIc@s(eZdZdd�Zdd�ZdS)�
_Log10MemoizecCs
d|_dS)NZ/23025850929940456840179914546843642076011014886)rv)r.r'r'r)r��sz_Log10Memoize.__init__cCs�|dkrtd��|t|j�kr�d}x^d||d}tttd||�d��}||d�d|kr�P|d7}q6W|jd�dd	�|_t|jd|d��S)
Nr%zp should be nonnegativerZr�r+rrQr-r�)rjrdrvr_r�r�r�rS)r.rrr�rvr'r'r)�	getdigits�s	"z_Log10Memoize.getdigitsN)r1r2r3r�r�r'r'r'r)r��sr�c	Cs�t||>|�}tdtt|��d|�}t||�}||>}x9t|ddd�D]!}t|||||�}qiWxCt|ddd	�D]+}||d>}t||||�}q�W||S)
Nr�rZr-r%r+i����r�r�r�)r	rSrdr_r�r�)	r
r�r�r�r�rZMshiftrr�r'r'r)�_iexp�s%
r�c	Cs�|d7}td|tt|��d�}||}||}|dkr^|d|}n|d|}t|t|��\}}t|d|�}tt|d|�d�||dfS)Nr+r%r-r�i�rZ)r�rdr_r�r�r�r�)	r-r�rrr�r�ZcshiftZquotrr'r'r)r;s
#

r;cCs*ttt|���|}t||||d�}||}|dkra||d|}nt||d|�}|dkr�tt|��|dk|dkkr�d|ddd|}	}
q d|d|}	}
n:t||d|d�\}	}
t|	d�}	|
d7}
|	|
fS)Nr-r%r�)rdr_rfrIr�r;)rrrrrrUZlxcr�Zpcr�rUr'r'r)r=s
( !
rr�r�2�F�3�5�4�(�5��6rC�7��8r�r=rwcCs>|dkrtd��t|�}dt|�||dS)Nr%z0The argument to _log10_lb should be nonnegative.r)rjr_rd)r-Z
correctionZstr_cr'r'r)rgsrcCsht|t�r|St|t�r,t|�S|rNt|t�rNtj|�S|rdtd|��tS)NzUnable to convert %s to Decimal)r^rrSrnrorpr�)r�r�Zallow_floatr'r'r)r�rs

r�cCst|t�r||fSt|tj�ru|jsbt|jtt|j	�|j
�|j�}|t|j�fS|r�t|tj
�r�|jdkr�|j}t|t�r�t�}|r�d|jt<n|jtd�|tj|�fSttfS)Nr%r-z;strict semantics for mixing floats and Decimals are enabled)r^r�_numbersZRationalrPr5r6r_rSr7�denominatorrO�	numeratorZComplexr�r�rnrrrrbror�)r.r�r�r/r'r'r)r��s$
		'			r�r?rr>rrr@i?Br$r�r�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
tj|�}|dkr+td|��|j�}|d}|d}|ddk	|d<|dr�|dk	r�td|��|dk	r�td|��|p�d|d<|p�d|d<|d	dkr�d
|d	<t|dp�d�|d<|d
dk	rt|d
�|d
<|d
dkrS|ddksI|ddkrSd|d
<|ddkr�d|d<|dkr�tj�}|ddk	r�td|��|d|d<|d|d<|d|d<n4|ddkr�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: � �>r<rR�minimumwidthrQrur%rmZgGnr-r4rs�
thousands_sepzJExplicit thousands separator conflicts with 'n' type in format specifier: �grouping�
decimal_pointrTrZr�)�_parse_format_specifier_regex�matchrj�	groupdictrS�_locale�
localeconv)�format_specrqrsZformat_dictr�r�r'r'r)rwsN





 




rwc	Cs�|d}|d}||t|�t|�}|d}|dkrY|||}n�|dkrv|||}nn|dkr�|||}nQ|dkr�t|�d}|d|�||||d�}ntd	��|S)
Nr�r�r��<r��=�^r+zUnrecognised alignment field)rdrj)	r<r|r{r�r�Zpaddingr�r�Zhalfr'r'r)rybs


)rycCs�ddlm}m}|s gS|ddkrct|�dkrc||dd�||d��S|d	tjkr�|dd
�Std��dS)Nr%)�chain�repeatr-r+z unrecognised format for groupingr�r�r�r�r�)�	itertoolsr�r�rdr��CHAR_MAXrj)r�r�r�r'r'r)�_group_lengths}s
"!r�cCs(|d}|d}g}x�t|�D]�}|dkrEtd��ttt|�|d�|�}|jd|t|�||d��|d|�}||8}|r�|dkr�P|t|�8}q'Wtt|�|d�}|jd|t|�||d��|jt|��S)Nr�r�r%zgroup length should be positiver-rQ)r�rjr�r�rdrkrl�reversed)rvr{�	min_width�sepr��groupsr.r'r'r)�_insert_thousands_sep�s 

!*
*r�cCs*|r
dS|ddkr"|dSdSdS)NrRr<z +rTr')�is_negativer{r'r'r)rx�s
rxcCs�t||�}|s|dr-|d|}|dksI|ddkr�ddddddd	di|d}|d
j||�7}|ddkr�|d7}|dr�|d
t|�t|�}nd}t|||�}t||||�S)NZaltr�r%rmrvr�r�rtrsz{0}{1:+}rrr�r�)rx�formatrdr�ry)r�rtrurUr{r<Zecharr�r'r'r)rz�s&

!rzZInfz-Infr�)|�__all__r1rC�__version__Z__libmpdec_version__�mathrxZnumbersr�rD�collectionsr&Z_namedtupler�ImportErrorrrrrrrrrr$�maxsizer r!r"r#�ArithmeticErrorrrr	r�ZeroDivisionErrorr
rrrrrr
rrrprrr�r�rIr\rArErK�hasattrrJrFrrrrr5�Number�registerrMrrgr�rSr~r	r
r�r�r�r�rLrIr�r�r�r�r;rrr�r�rrr�re�compile�VERBOSE�
IGNORECASEr�r`r�r��DOTALLr��localer�rwryr�r�rxrzrHrGr9r7rr6r;�	hash_info�modulusr�rcr�r�r�r�r�r'r'r'r)�<module>usT			


&

	
.��������������������	0",#%$+'	*			

P%
)


Hacked By AnonymousFox1.0, Coded By AnonymousFox