Qfw  gdZeZdZdZdZddlZddlZddl Z ddl m Z e ddd Z d Zd Zd ZdZdZdZdZdZdZdZe j2dk(rdZdZdZndZdZdZeedz z ZGddeZGddeZ GddeZ!Gd d!e!Z"Gd"d#ee#Z$Gd$d%e!Z%Gd&d'e!e#Z&Gd(d)eZ'Gd*d+e!Z(Gd,d-eZ)Gd.d/eZ*Gd0d1e'e)Z+Gd2d3e'e)e*Z,Gd4d5ee-Z.e e$e'e+e)e,e!e*e.g Z/e"e!e%e!e&e!e(e!iZ0eeeeeeeefZ1ddl2Z2e2jfd6Z4e5gd7Z6d8Z7d9Z8[2dsd:Z9Gd;dd?e:Z?Gd@dAe:Z@GdBdCe:ZAdudDZBeCjZEdEZFdFZGdGZHdHZIdvdIZJdJZKdKZLGdLdMe:ZMeMjZOdvdNZPdOZQdPZRdQdRdSdTdUdVdWdXdYdZ fd[ZSdwd\ZTdtd]ZUe@d^ee$e+e!ggd_d`ddaZVe@dbee$e+e!e e,ggcZWe@dbeggcZXddlYZYeYjddeYjeYjzjZ^eYjdejZ_eYjdfjZ`eYjdgeYjeYjzZb[Y ddlcZddsdhZediZfdjZgdxdkZhdlZidmZje;dnZke;doZle;dpZme;dZne;dZoe;dqZpekelfZqe jjZte jjZve jjZxeydXetdrz etZz[ y#e$rd Z YDwxYw#e$rYwxYw)y)%DecimalContext DecimalTupleDefaultContext BasicContextExtendedContextDecimalExceptionClampedInvalidOperationDivisionByZeroInexactRounded SubnormalOverflow UnderflowFloatOperationDivisionImpossibleInvalidContextConversionSyntaxDivisionUndefined ROUND_DOWN ROUND_HALF_UPROUND_HALF_EVEN ROUND_CEILING ROUND_FLOORROUND_UPROUND_HALF_DOWN ROUND_05UP setcontext getcontext localcontextMAX_PRECMAX_EMAXMIN_EMIN MIN_ETINY HAVE_THREADSHAVE_CONTEXTVARdecimalz1.70z2.4.2N) namedtuplerzsign digits exponent)modulec|SN)argss 1/opt/alt/python312/lib64/python3.12/_pydecimal.pyr0CsrrrrrrrrTllNZolNZoi@TiceZdZ dZy)rcyr,r-selfcontextr.s r/handlezDecimalException.handlers r1N__name__ __module__ __qualname__r8r-r1r/rr_s $ r1rc eZdZy)r Nr:r;r<r-r1r/r r v r1r ceZdZ dZy)r c|r9t|dj|djdd}|j|StS)Nr(nT)_dec_from_triple_sign_int_fix_nan_NaN)r6r7r.anss r/r8zInvalidOperation.handles9 "47==$q',,TJC<<( ( r1Nr9r-r1r/r r s ,r1r ceZdZ dZy)rctSr,rGr5s r/r8zConversionSyntax.handle r1Nr9r-r1r/rrs  r1rceZdZ dZy)r ct|Sr,)_SignedInfinityr6r7signr.s r/r8zDivisionByZero.handles t$$r1Nr9r-r1r/r r s  %r1r ceZdZ dZy)rctSr,rKr5s r/r8zDivisionImpossible.handlerLr1Nr9r-r1r/rr r1rceZdZ dZy)rctSr,rKr5s r/r8zDivisionUndefined.handlerLr1Nr9r-r1r/rrrTr1rc eZdZy)r Nr>r-r1r/r r r?r1r ceZdZ dZy)rctSr,rKr5s r/r8zInvalidContext.handlerLr1Nr9r-r1r/rrs r1rc eZdZy)r Nr>r-r1r/r r r?r1r c eZdZy)rNr>r-r1r/rrsr1rceZdZ dZy)rc|jttttfvr t |S|dk(rP|jt k(r t |St|d|jz|j|jz dzS|dk(rP|jtk(r t |St|d|jz|j|jz dzSy)Nr(9r2) roundingrrrrrOrrCprecEmaxrrPs r/r8zOverflow.handles     / ; ;"4( ( 19=0&t,,#D#gll*:#LL5a79 9 19;.&t,,#D#gll*:$\\',,6q8: : r1Nr9r-r1r/rrs * :r1rc eZdZy)rNr>r-r1r/rr& r1rc eZdZy)rNr>r-r1r/rr5rcr1rdecimal_context)r`Eminracapitalsclampr_flagstrapsc tjS#t$r$t}tj ||cYSwxYwr,)_current_context_varget LookupErrorrsetr7s r/rr_sD #'')) )  )s*AAc |tttfvr |j}|j t j |yr,)rrrcopy clear_flagsrlrorps r/rrms9/><AA,,.W%r1c | t}t|}|jD]3\}}|tvrt d|dt |j ||5|S)N'z2' is an invalid keyword argument for this function)r_ContextManageritems_context_attributes TypeErrorsetattr new_context)ctxkwargs ctx_managerkeyvalues r/r r vsl"F {l!#&Klln U ) )au$VWX X ''e4% r1c eZdZ dZdydZedZdZdZdzdZ dZ d Z d Z d{d Z d{d Zd{d Zd{dZd{dZd{dZdZdZdZdZd|dZd{dZd{dZd{dZd}dZd{dZeZd{dZd{dZd{dZ e Z!d{dZ"dZ#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/Z5d0Z6d1Z7d2Z8d3Z9d4Z:d5Z;d6Ze6e7e8e9e:e;eZEdzd?ZFd{d@ZGd{dAZHdzdBZId{dCZJdDZKdEZLdzdFZMdzdGZNeNZOd{dHZPd{dIZQd{dJZRdKZSdLZTdMZUdNZVd{dOZWd{dPZXd{dQZYdRZZdSZ[d{dTZ\d{dUZ]dVZ^dWZ_dXZ`dYZad{dZZbd[Zcd\Zdd]Zed{d^Zfd_Zgd`Zhd{daZidbZjd{dcZkd{ddZldeZmdfZnd{dgZod{dhZpd{diZqd{djZrd{dkZsd{dlZtd{dmZud{dnZvd{doZwd{dpZxdqZyd{drZzd{dsZ{d{dtZ|duZ}dvZ~dwZdzdxZy)~r)_exprErD _is_specialNc: tj|}t|trht |j j dd}|%| t}|jtd|zS|jddk(rd|_ nd|_ |jd}|k|jd xsd}t|jd xsd }tt||z|_ |t|z |_d |_|S|jd }|Mtt|xsd j#d |_ |jdrd|_nd|_nd |_ d|_d|_|St|tr=|dk\rd|_ nd|_ d|_tt%||_ d |_|St|t&rF|j|_|j|_ |j|_ |j |_|St|t(rN|j*|_ t|j|_ t|j,|_d |_|St|t.t0frZt|dk7r t3dt|dtr|ddvs t3d|d|_ |ddk(rd |_ |d|_d|_|Sg} |dD]N} t| tr2d| cxkrdkr'n t3d| s| dk7s3| j5| Et3d|ddvr7dj7t9t| |_ |d|_d|_|St|dtr?? eU #$,   &&u-EDIDJDI % 1 1D K6>??r1c t|tr |dk\rdnd}d}tt|}nt|trt j |st j|r|t|St jd|dk(rd}nd}t|j\}}|jdz }t|d|zz}n tdt||| }|tur|S||S)Nr(r2g?zargument must be int or float.)rrrrr_mathisinfisnanreprcopysignas_integer_ratio bit_lengthryrCr)rfrQkcoeffrBdresults r/rzDecimal.from_floatIs ( a Q1ADAAKE 5 !{{1~Q47|#~~c1%,q6**,DAq "A!Q$KE<= =!$r2 '>Mv; r1cN |jr|j}|dk(ry|dk(ryy)NrBr2rrr()rr)r6rs r/_isnanzDecimal._isnanvs2   ))Cczr1c@ |jdk(r|jryyy)Nrr2r()rrDr6s r/ _isinfinityzDecimal._isinfinitys% 99 zzr1c( |j}|d}n|j}|s|rh| t}|dk(r|jtd|S|dk(r|jtd|S|r|j |S|j |Sy)NFrsNaNr()rrrr rF)r6otherr7 self_is_nan other_is_nans r/ _check_nanszDecimal._check_nanss kkm = L <<>L ,$,a++,>'* *r1c | t}|js |jr|jr|jtd|S|jr|jtd|S|j r|jtd|S|j r|jtd|Sy)Nzcomparison involving sNaNzcomparison involving NaNr()rris_snanrr is_qnanr6rr7s r/_compare_check_nanszDecimal._compare_check_nanss  ? lG   u00||~++,<,G,022++,<,G,133++,<,F,022++,<,F,133r1c> |jxs|jdk7SNrrrErs r/__bool__zDecimal.__bool__s# 3499#33r1c |js |jr-|j}|j}||k(ry||kryy|s|syd|jz S|sd|jzS|j|jkry|j|jkry|j}|j}||k(r||jd|j |j z zz}|jd|j |j z zz}||k(ry||krd|jz Sd|jzS||kDrd|jzSd|jz S)Nr(rr2r)rrrDadjustedrEr)r6rself_inf other_inf self_adjustedother_adjusted self_padded other_paddeds r/_cmpz Decimal._cmpsc D   u00'')H))+I9$I%u{{*++# # ;; # :: #  ) N *))c499uzz+A&BBK ::UZZ$))-C(DDLl*|+djj(((TZZ'' ^ +# #4::%& &r1ct||d\}}|tur|S|j||ry|j|dk(S)NT) equality_opFr()_convert_for_comparisonNotImplementedrrrs r/__eq__zDecimal.__eq__sH-dEtL e N "L   E7 +yy1$$r1ct||\}}|tur|S|j||}|ry|j|dkSNFr(rrrrr6rr7rHs r/__lt__zDecimal.__lt__"K-dE: e N "L&&ug6 yy!##r1ct||\}}|tur|S|j||}|ry|j|dkSrrrs r/__le__zDecimal.__le__+K-dE: e N "L&&ug6 yy1$$r1ct||\}}|tur|S|j||}|ry|j|dkDSrrrs r/__gt__zDecimal.__gt__4rr1ct||\}}|tur|S|j||}|ry|j|dk\Srrrs r/__ge__zDecimal.__ge__=rr1c t|d}|js|r"|jr|j||}|r|St|j |SNTraiseit)_convert_otherrrrrrs r/comparezDecimal.compareFsX ud3   %*;*;""5'2C tyy'((r1c |jrY|jr td|jrtj |S|j rt StS|jdk\rtd|jt}n tt|j t}t|j|ztz}|dk\r|n| }|dk(rdS|S)Nz"Cannot hash a signaling NaN value.r( r)rrryis_nanr__hash__rD _PyHASH_INFrpow_PyHASH_MODULUS _PyHASH_10INVrrE)r6exp_hashhash_rHs r/rzDecimal.__hash__Xs'   ||~ DEEt,,::'<'&& 99>2tyy/:H=499*oFHDII)O;qyeufBYr'C'r1c  t|jttt|j |j Sr,)rrDrrrrErrs r/as_tuplezDecimal.as_tuplers0 DJJc#tyy.A(BDIINNr1c |jr&|jr tdtd|syt |j }|j dk\r|d|j zzd}}nt|j }|dkDr |dzdk(r|dz}|dz}|dkDr |dzdk(r|j }t|| zjdz |}|r ||z}||z}d|z|z}|jr| }||fS)Nz#cannot convert NaN to integer ratioz(cannot convert Infinity to integer ratiorr(rr2r) rrr OverflowErrorrrErminrrD)r6rBrd5d2shift2s r/rzDecimal.as_integer_ratioys    {{} !FGG#$NOO  N 99>r499}$aqA))Bq&QUaZaaq&QUaZ ))B!qb&,,.2B7Ff f 2 A ::A!t r1c dt|zS)Nz Decimal('%s'))rrs r/__repr__zDecimal.__repr__s>T**r1c  ddg|j}|jrG|jdk(r|dzS|jdk(r|dz|jzS|dz|jzS|jt |jz}|jdkr|d kDr|}n+|sd }n&|jd k(r |d zd zd z }n |d z d zd z}|dkrd }d d | zz|jz}nd|t |jk\r+|jd |t |jz zz}d}n!|jd|}d |j|dz}||k(rd}n&| t }ddg|j d||z zz}||z|z|zS)NrrrInfinityrBNaNrr(r2rr.eEz%+d)rDrrrErrrg) r6engr7rQ leftdigitsdotplacerrrs r/__str__zDecimal.__str__s Cy$   yyCj((c!e|dii//f}tyy00YYTYY/ 99>j2o!HH YY# "Q!+a/H#Q!+a/H q=GS8)_,tyy8H TYY 'iiXc$))n%< ==GHii *GTYYxy11H  !C$,*W--.*X:M1NNCg~(3..r1c* |jd|S)NT)rr7)rr6r7s r/ to_eng_stringzDecimal.to_eng_strings ||g|66r1c |jr|j|}|r|S| t}|s$|jtk7r|j }n|j }|j|SNrp)rrrr_rcopy_abs copy_negate_fixr6r7rHs r/__neg__zDecimal.__neg__ss    ""7"3C ? lG((K7--/C""$Cxx  r1c |jr|j|}|r|S| t}|s$|jtk7r|j }n t |}|j|Sr)rrrr_rrrrrs r/__pos__zDecimal.__pos__sl    ""7"3C ? lG((K7--/C$-Cxx  r1c |s|jS|jr|j|}|r|S|jr|j |}|S|j |}|Sr)rrrrDrr )r6roundr7rHs r/__abs__zDecimal.__abs__sq ==? "   ""7"3C ::,,w,/C ,,w,/C r1c> t|}|tur|S| t}|js |jr|j ||}|r|S|j rJ|j |j k7r&|j r|jtdSt|S|j r t|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()rrrrrrrDrr rrrr_rrCrmaxr`_rescaler _normalizerQrr) r6rr7rHr negativezerorQop1op2rs r/__add__zDecimal.__add__.s u% N "L ? lG   u00""5'2C !::,1B1B1D"//0@,OOt}$  "u~%$))UZZ(   { *tzzU[[/HLEtzz5;;/D"4c2C((7#CJc5:: 4Q67C..g&6&67C((7#CJc499w||3A56C--W%5%56C((7#CJtnuoc3 5S 88sxx ww#''!&|S#>hhw' ww Sxx1} %(XXsxx"#( XX]FK!' CHchFK 88q=377*FJ377*FJWW fohhw r1c t|}|tur|S|js |jr|j||}|r|S|j |j |Sr)rrrrr+rrs r/__sub__zDecimal.__sub__sh!u% N "L   u00""5'":C ||E--/|AAr1cT t|}|tur|S|j||Sr)rrr-rs r/__rsub__zDecimal.__rsub__s/!u% N "L}}T7}33r1c t|}|tur|S| t}|j|jz }|js |jrx|j ||}|r|S|j r!|s|jtdSt|S|j r!|s|jtdSt|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 * 0z 0 * (+-)INFr1)rrrrDrrrrr rOrrCrrErrr)r6rr7 resultsignrH resultexpr)r*s r/__mul__zDecimal.__mul__s u% N "L ? lGZZ%++-   u00""5'2C !"//0@-PP&z22  ""//0@-PP&z22II * 5":sI>C((7#CJ 99 ":uzz9EC((7#CJ :: ":tyy)DC((7#CJtnuoz3sww/@+A9Mhhw r1c t|}|turtS| t}|j|jz }|js |jr|j ||}|r|S|j r&|j r|jtdS|j r t|S|j r1|jtdt|d|jS|s/|s|jtdS|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(rt|t-||}|j/|S) Nz(+-)INF/(+-)INFzDivision by infinityrz0 / 0zx / 0r(r2rr)rrrrDrrrrr rOr rCEtinyrr rrrEr`rdivmodrrr) r6rr7rQrHrrshiftr)r* remainder ideal_exps r/ __truediv__zDecimal.__truediv__sJ"u% N "! ! ? lGzzEKK'   u00""5'2C !e&7&7&9++,<>OPP!&t,,  "$$W.DE'c7==?CC++,=wGG''F F))ejj(CE Oc$))n4w||CaGE))ejj(50C4.C5/Cz#)#''BI*=sww#G y#)#''377R%Z3G#H y19>QJE!II 2 Io%"*/bLE1HCIo%"*/tSZ5xx  r1c |j|jz }|jr |j}n t|j|j}|j |j z }|r|js|dkr)t |dd|j ||jfS||jkrt|}t|}|j|jk\r0|xjd|j|jz zzc_ n/|xjd|j|jz zzc_ t|j|j\}} |d|jzkr6t |t|dt |jt| |fS|jtd} | | fS)Nrrr(rz%quotient too large in //, % or divmod)rDrrrrrCr&r_r`rrrr7rrr) r6rr7rQr:expdiffr)r*qrrHs r/_dividezDecimal._divides zzEKK'     IDIIuzz2I--/ENN$44u((*gm$T32MM)W-=-=>@ @ gll "4.C5/Cww#''!2#'' 1222#'' 122#''377+DAq2w||##(s1vq9(SVYGII""#5#JLCxr1cT t|}|tur|S|j||Sr)rrr;rs r/ __rtruediv__zDecimal.__rtruediv__1s27u% N "L  w 77r1cD t|}|tur|S| t}|j||}|r||fS|j|jz }|j rI|j r|j td}||fSt||j tdfS|sI|s|j td}||fS|j td||j tdfS|j||\}}|j|}||fS)Nzdivmod(INF, INF)INF % xz divmod(0, 0)x // 0x % 0) rrrrrDrrr rOrr r@r)r6rr7rHrQquotientr9s r/ __divmod__zDecimal.__divmod__8s: u% N "L ? lGug. : zzEKK'      "**+;=OPCx'-,,-=yIKK**+r?rQs r/remainder_nearzDecimal.remainder_nears~  ? lGud3ug. J    ''(8(EG G++,<,BDD++,=,BDD    $-C88G$ $TYY 3"4::sNCC88G$ $--/ENN$44 gllQ& &''(:; ; b=--0@0@AC88G$ $tnuo 77cgg  GGrCGGcgg-. .G GGrCGGcgg-. .Gcggsww'1 Q3!A#; LA FA GLL ''(:; ;zz q5T6DAtSV^<xx  r1c t|}|tur|S| t}|j||}|r|S|j rF|j r|j t dSt|j|jz S|sF|r.|j td|j|jz S|j tdS|j||dS)Nz INF // INFrEz0 // 0r() rrrrrrr rOrDr rr@rs r/ __floordiv__zDecimal.__floordiv__su% N "L ? lGug. J      "++,S^#B M1 1S:DII.5#66 6r1c|Sr,r-rs r/realz Decimal.real s r1ctdSNr(rrs r/imagz Decimal.imags qzr1c|Sr,r-rs r/ conjugatezDecimal.conjugates r1c*tt|Sr,)complexrrs r/ __complex__zDecimal.__complex__suT{##r1c |j}|j|jz }t||kDrB|t||z dj d}t |j ||jdSt|S)NrT) rEr`rhrrrCrDrr)r6r7payloadmax_payload_lens r/rFzDecimal._fix_nansr@))",,6 w&&xtzzJC   )   )J#eO G 99w ^dii/'9Fz' CC"::7;K;KLO%dF3GIIgv&-#E{CJqL)u: ,!#2JEqLG~**8\4::N&tzz5'B,$$Y/ $$Y/$$W-   )$$W-J    + ==A $))d"2   )))c499t+;&<??4==O455r1c |jr&|jr tdtdt |j dt SNrrr()rrrrrr&rrs r/ __floor__zDecimal.__floor__ sI    {{} !566#$>??4==K011r1c |jr&|jr tdtdt |j dt Sr)rrrrrr&rrs r/__ceil__zDecimal.__ceil__sI    {{} !566#$>??4==M233r1c  t|d}t|d}|js |jr | t}|jdk(r|j t d|S|jdk(r|j t d|S|jdk(r|}n|jdk(r|}n|jdk(r9|s|j t dSt |j|jz }n|jdk(r|s|j t dSt |j|jz }nmt|j|jz tt|jt|jz|j|jz}j||S) NTrrrrBrzINF * 0 in fmaz0 * INF in fma) rrrrrr rOrDrCrrrEr+)r6rthirdr7products r/fmaz Decimal.fma+s ud3ud3   u00$,yyC++,C O+K'L'+yy5::'=?Gug..r1cD 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|jr |jr|js|j t dS|dkr|j t dS|s|j t dS|j|jk\r|j t dS|s|s|j t dS|jrd}n |j}tt|}t|j}t|j} |j|zt!d |j"|z|z}t%| j"D]} t!|d |}t!|| j|}t'|t)|dS) Nrrz@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)rrrrrr rF _isintegerrr`_isevenrDrrrto_integral_valuerrrangerCr) r6rmodulor7rr modulo_is_nanrQbaseexponentis r/ _power_modulozDecimal._power_moduloWs/u% N "L' ^ #M ? lGkkm ||~   ,-a++,? ? ==?D::DS[!..01E33566!CDHHf$==Gx||$AtR(D%4v.c$i33r1c t|}|j|j}}|dzdk(r|dz}|dz }|dzdk(rt|}|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(rt|d zdz} td | z|\}}|ry|d zdk(r|d z}| dz} |d zdk(r|dzd z}|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(rn|d z|d zcxk(rdk(r!nn|d z}|d z}|d z|d zcxk(rdk(rn|dkDrf|kryt||\}}|dk7rydt| |z z} 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)Nrr(r2r1r)r]Arrrd)rrrrQrrDrrrC_nbitsrr_decimal_lshift_exactr7r _log10_lb)r6rpxxcxeyycyerrQzeros last_digitremaxr9strxcrrBxc_bitsremar>r?str_xcs r/ _power_exactzDecimal._power_exacts- Br TNB2gl 2IB !GB2gl UOB2gl 2IB !GB2gl 7 "HBr'Q,r ar'Q,AvBF{Hvv{$9!ekkQ&6!%3u:!5H^3QqS9#AsSYG G 66Q;bJY&8r>2JqL6tRxSY'*!b&"5*27B79 t8Tq2JrM2% &q!tR 0 I1fk1HBFA1fktQwSY')!b&"5*27B79 t8TGE5zA~BB#Aub1 1 7b"f9aqAQw3s3r"u:/B36RjG3s2ww'(RC/rRCyqAa%1q5%A%aaa%1q5%A%a%1q5%A%aaa%1q5%A% q5!|RmGBaxr {A~&&Ab!ac(+16AaC1q(A  FqAvB 6a!C%2.. U a R v;?    %++"2!YYs5z1N>)1S[=9EE6#e)#3RX>>r1c\ ||j|||St|}|tur|S| t}|j ||}|r|S|s|s|j t dStSd}|jdk(rK|jr|jsd}n|r|j t dS|j}|s%|jdk(r t|ddSt|S|jr%|jdk(r t|St|ddS|tk(r|jr|jdk(rd}n'||jkDr |j}n t!|}|j"|z}|d|jz kr^d|jz }|j t$n9|j t&|j t$d|jz }t|dd| zz|S|j)}|jr+|jdk(|dkk(r t|ddSt|Sd}d} |j+|j)z} |dk\|jdk(k(r<| t-t/|j0k\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 d t-t/|| z dz zzzrn|d z }?t|t/||}| r|jszt-|j6|jkrY|jdzt-|j6z }t|j|j6d|zz|j"|z }|jA}|jCtDD]}d|jF|<|jI|}|j t&|jJtLr|j tN|jJtPr!|j tPd |jtNtLt&t$tRfD]#}|jJ|s|j |%|S|jI|}|S) Nz0 ** 0r(r2z+x ** y with x negative and y not an integerrr1FTrrrrm)*rrrrrrr _OnerDrrrrCrOrr`rrr r r_log10_exp_boundrrrar6rrErrrQ_dpowerrrrs_signalsrjrrirrrr )r6rrr7rH result_sign multiplierrself_adjexactboundr6rrrrrrrextrarr= newcontext exceptions r/__pow__zDecimal.__pow__sC .  %%eVW= =u% N "L ? lGug. J++,3??r1cb t|d}| t}| |j}|js |jrw|j ||}|r|S|j s|j rA|j r|j r t |S|jtdS|j|jcxkr|jksn|jtdS|s2t|jd|j}|j|S|j}||jkDr|jtdS||jz dz|j kDr|jtdS|j#|j|}|j|jkDr|jtdSt%|j&|j kDr|jtdS|r2|j|j(kr|jt*|j|jkDr/||k7r|jt,|jt.|j|}|S) NTrzquantize with one INFz)target exponent out of bounds in quantizerz9exponent of quantize result too large for current contextr2z7quantize result has too many digits for current context)rrr_rrrrrr r6rrarCrDrrr`r&rrErfrr r )r6rr_r7rHrs r/rzDecimal.quantize sQ S$/ ? lG  ''H   s""30C  D$4$4$6??$)9)9);"4=(++,<(?AA 388;w||;''(8>@ @"4::sCHH=C88G$ $  7<< '''(8(ce e 388 #a '',, 6''(8(ac cmmCHHh/ <<>GLL (''(8(ce e sxx=7<< '''(8(ac c 3<<>GLL0   + 88dii d{$$W-   )hhw r1c  t|d}|js |jrF|jxr|jxs"|jxr|jS|j|jk(Sr)rrr is_infiniterrs r/ same_quantumzDecimal.same_quantum sr ud3   u00KKM4elln?$$&>5+<+<+> @yyEJJ&&r1c2 |jr t|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)Nrr(r1r2) rrrCrDrrErrorr)r6rr_r this_functionrurs r/r&zDecimal._rescale s     4= #DJJS9 9 99 #DJJ(, CS4I(I3P P TYY$))+c1 A:#DJJSU;DF44X> f- '6")c a<E 1 %E E377r1c4 |dkr td|js|s t|S|j|j dz|z |}|j |j k7r&|j|j dz|z |}|S)Nr(z'argument should be at least 1 in _roundr2)rrrr&r)r6placesr_rHs r/_roundzDecimal._round s  Q;FG G   44= mmDMMOA-f4h? <<>T]]_ ,,,s||~a/6AC r1c~ |jr!|j|}|r|St|S|jdk\r t|S|st |j ddS| t }| |j}|jd|}||k7r|jt|jt|S)Nrpr(r) rrrrrCrDrr_r&rr r r6r_r7rHs r/to_integral_exactzDecimal.to_integral_exact! s    ""7"3C 4= 99>4= #DJJQ7 7 ? lG  ''HmmAx( $;   )W% r1c | t}| |j}|jr!|j|}|r|St |S|j dk\r t |S|j d|S)Nrpr()rr_rrrrr&rs r/rzDecimal.to_integral_value> svN ? lG  ''H   ""7"3C 4= 99>4= ==H- -r1c. | t}|jr@|j|}|r|S|jr|jdk(r t |S|s5t |jd|jdz}|j|S|jdk(r|jtdS|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(rrr2zsqrt(-x), x > 0rrTr)rrrrrDrrCrrrr r`rrrrrEr7r _shallow_copy _set_roundingrr_)r6r7rHr`oprclr8rr9rBr>r_s r/sqrtz Decimal.sqrtQ s:- ? lG   ""7"3C !djjAot}$"4::sDIINCC88G$ $ ::?''(8:KL L,||A~ d^ FFaK 66A: ATYY1$)AADIIq A%AQ A: eOAE!!S5&[1LAy!ME U  H1AAvEQJ  "!A#( zb%iR%Z JA1uzQq#a&!,'')((9hhw# 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 |SNTrr2r(rrrrrrrr compare_totalr6rr7snonrrHs r/r%z Decimal.max s ud3 ? lG   u00BBR7rQw99W--7rQw ::g..''w77 IIe  6""5)A 7CCxx  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 |Srrrs r/rz Decimal.min s ud3 ? lG   u00BBR7rQw99W--7rQw ::g..''w77 IIe  6""5)A 7CCxx  r1c |jry|jdk\ry|j|jd}|dt|zk(S)NFr(Tr)rrrEr)r6rests r/rzDecimal._isinteger sF0    99>yy$s3t9}$$r1cd |r|jdkDry|jd|jzdvS)Nr(Trr)rrErs r/rzDecimal._iseven s1Htyy1}yyDII&'11r1cn |jt|jzdz S#t$rYywxYw)Nr2r()rrrEryrs r/rzDecimal.adjusted s82 99s499~-1 1  s $( 44c |Sr,r-rs r/ canonicalzDecimal.canonical s  r1cp t|d}|j||}|r|S|j||SNTrrp)rrrrs r/compare_signalzDecimal.compare_signal sB u5&&ug6 J||E7|33r1cd 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)NTrr2r) rrD _NegativeOnerrrrE_Zeror)r6rr7rQself_nan other_nanself_key other_keys r/rzDecimal.compare_total+ s ud3 ::ekk zzekkKzz;;=LLN y9$tyy>4994 OUZZ7 i'# ++i'++#  q=''>Kq=''>Kq=K>''q=K>'' %<  %<K 99uzz ! ## 99uzz !##  r1c t|d}|j}|j}|j|Sr)rrr)r6rr7rZos r/compare_total_magzDecimal.compare_total_magt s; ud3 MMO NN q!!r1c\ td|j|j|jSra)rCrErrrs r/rzDecimal.copy_abs s$5499dii9I9IJJr1c |jr,td|j|j|jStd|j|j|jS)Nr(r2)rDrCrErrrs r/rzDecimal.copy_negate sJ4 ::#Atyy$))T=M=MN N#Atyy$))T=M=MN Nr1c t|d}t|j|j|j|j Sr)rrCrDrErrrs r/ copy_signzDecimal.copy_sign s92ud3 TYY $ 4+;+;= =r1c | t}|j|}|r|S|jdk(rtS|stS|jdk(r t |S|j }|j}|jdk(rC|tt|jdzdzkDrtdd|jdz}nE|jdk(rK|tt|j dzdzkDrtdd|jdz }n|jdk(r!|| krtddd|dz zzdz| }n|jdk(r!|| dz krtdd|dzz| dz }nt|}|j|j }}|j"dk(r| }d} t%||||z\} } | d d tt| |z dz zzzrn|dz }=tdt| | }|j'}|j)t*} |j-|}| |_|S) Nrprr2r(rr1rr^rr)rrrrrrr`rrDrrrarCr6rrrrQ_dexprrrrr_) r6r7rHradjrrrrrrr_s r/rz Decimal.exp sE ? lGw/ J     #LK     "4= LLmmo ::?sSgll1na-?)@%AA"1c7<<>:C ZZ1_s30@0BA/E+F'G!G"1c7==?1+<=C ZZ1_r"1cC1Io&;aR@C ZZ1_r!t"1c1Q3i!A6C$B66266qAww!|B E"1a51 sAb3s5z?1#4Q#6778   #1c%j#6C'')((9hhw# r1c y)NTr-rs r/ is_canonicalzDecimal.is_canonical s  r1c |j Sr,)rrs r/ is_finitezDecimal.is_finite s ####r1c" |jdk(S)Nrrrs r/rzDecimal.is_infinite sFyyCr1c |jdvS)Nrrrs r/rzDecimal.is_nan sLyyJ&&r1ct |js|sy| t}|j|jkSNF)rrrfrrs r/ is_normalzDecimal.is_normal s4M   4 ? lG||t}}..r1c" |jdk(S)NrBrrs r/rzDecimal.is_qnan sIyyCr1c" |jdk(SNr2)rDrs r/ is_signedzDecimal.is_signed sFzzQr1c" |jdk(S)Nrrrs r/rzDecimal.is_snan sMyyCr1ct |js|sy| t}|j|jkSr)rrrrfrs r/ is_subnormalzDecimal.is_subnormal s4G   4 ? lG}}--r1c@ |j xr|jdk(Srrrs r/is_zerozDecimal.is_zero s"D###8 S(88r1c |jt|jzdz }|dk\rtt|dzdzdz S|dkr ttd|z dzdzdz St |}|j |j }}|dk(r:t|d| zz }t|}t|t|z ||kz S|ttd| z|z zdz S)Nr2rrrr(rrrErrrrr6r rrrnumdens r/ _ln_exp_boundzDecimal._ln_exp_bound s ii#dii.(1, !8s3r62:'!+ + "9sBsFB;?+,q0 0 d^vvrvv1 !8aQBh-Ca&Cs8c#h&#)4 43s2r6A:''!++r1c  | t}|j|}|r|S|stS|jdk(rtS|t k(rt S|jdk(r|jtdSt|}|j|j}}|j}||jz dz} t|||}|ddt!t#t%||z dz zzzrn|dz }@t't|dkt#t%|| }|j)}|j+t,} |j/|}| |_|S) Nrpr2zln of a negative valuerrrrr()rr_NegativeInfinityr _InfinityrrrDrr rrrr`r%_dlogrrrrCrrrrr_ r6r7rHrrrrrrr_s r/lnz Decimal.ln, sm= ? lGw/ J$ $     "  4<L ::?''(8(@B Bd^vvrvv1 LLT''))A-!Q'E"s3s5z?3A5a7889 aKF  s57|SU_vgF'')((9hhw# r1c |jt|jzdz }|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) Nr2rrr(rr231r!r"s r/rzDecimal._log10_exp_bound^ s ii#dii.(1, !8s3x=? " "9s2c6{#A% % d^vvrvv1 !8aQBh-Cc!e*Cs8c#h&#)4q8 8"qb&(m3x!|sU{+a//r1c  | t}|j|}|r|S|stS|jdk(rtS|j dk(r|j tdS|jddk(rZ|jdddt|jdz zk(r/t|jt|jzdz }nt|}|j|j}}|j}||j!z dz} t#|||}|dd tt%t'||z dz zzzrn|d z }@t)t|dkt%t'|| }|j+}|j-t.} |j1|}| |_|S) Nrpr2zlog10 of a negative valuer(r1rrrrr)rrr'rr(rDrr rErrrrrrr`r_dlog10rrrCrrrrr_r*s r/log10z Decimal.log10| s4 ? lGw/ J$ $     "  ::?''(8(CE E 99Q<3 499QR=CTYY!9K4L#L$))c$))n4q89C$B66266qA At,,..q0F1f-Ab3s3u:#7#9!#;<<=!   #3uQw<SZ6'JC'')((9hhw# r1c |j|}|r|S| t}|jrtS|s|j t ddSt |j}|j|S)Nrpzlogb(0)r2) rrrr(rr rrrrs r/logbz Decimal.logb s w/ J ? lG     '' 1E E dmmo&xx  r1cr |jdk7s|jdk7ry|jD]}|dvsyy)Nr(F01T)rDrrE)r6digs r/ _islogicalzDecimal._islogical s> ::?dii1n99C$r1c|jt|z }|dkDr d|z|z}n|dkr||j d}|jt|z }|dkDr d|z|z}||fS|dkr||j d}||fS)Nr(r)r`r)r6r7opaopbdifs r/ _fill_logicalzDecimal._fill_logical sllSX% 7c'C-C 1Ww||mn%CllSX% 7c'C-CCx1Ww||mn%CCxr1c  | t}t|d}|jr|js|jtS|j ||j |j \}}djt||Dcgc]%\}}tt|t|z'c}}}td|jdxsddScc}}wNTrrr(r rrr7rr r<rErziprrrCrr6rr7r9r:rbrs r/ logical_andzDecimal.logical_and I ? lGud3 (8(8(:''(89 9''EJJG cC E 1#c!fSVm, EF6==#5#<a@@F*C& cp | t}|jtdd|jzd|S)Nr(r1)r logical_xorrCr`rs r/logical_invertzDecimal.logical_invert s<$ ? lG 03w||3CA F ') )r1c  | t}t|d}|jr|js|jtS|j ||j |j \}}djt||Dcgc]%\}}tt|t|z'c}}}td|jdxsddScc}}wr>r?rAs r/ logical_orzDecimal.logical_or sH ? lGud3 (8(8(:''(89 9''EJJG cC E 1#c!fSVm, EF6==#5#<a@@FrEc  | t}t|d}|jr|js|jtS|j ||j |j \}}djt||Dcgc]%\}}tt|t|z 'c}}}td|jdxsddScc}}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 rrrrrrrrrrs r/max_magzDecimal.max_mag" sFud3 ? lG   u00BBR7rQw99W--7rQw ::g..''w77 MMO !1 2 6""5)A 7CCxx  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 |SrrMrs r/min_magzDecimal.min_mag@ sFud3 ? lG   u00BBR7rQw99W--7rQw ::g..''w77 MMO !1 2 6""5)A 7CCxx  r1c | t}|j|}|r|S|jdk(rtS|jdk(r(t dd|j z|j S|j}|jt|j|j|}||k7r|S|jt dd|jdz |S)Nrprr2r(r^r1)rrrr'rCr`rnrrrr_ignore_all_flagsrr-r6r6r7rHnew_selfs r/ next_minuszDecimal.next_minus^ sK ? lGw/ J     #$ $     "#As7<<'7H H,,.k*!!#99W% t O||,QW]]_Q5FG#% %r1c | t}|j|}|r|S|jdk(rtS|jdk(r(t dd|j z|j S|j}|jt|j|j|}||k7r|S|jt dd|jdz |S)Nrpr2rr^r(r1)rrrr(rCr`rnrrrrrRrr+r6rSs r/ next_pluszDecimal.next_plusu sK ? lGw/ J     "      ##As7<<'7H H,,.m,!!#99W% t O||,QW]]_Q5FG#% %r1c t|d}| t}|j||}|r|S|j|}|dk(r|j |S|dk(r|j |}n|j |}|jrM|jtd|j|jt|jt|S|j|jkrk|jt|jt |jt|jt|s|jt"|S)NTrr(rz Infinite result from next_toward)rrrrrrWrUrrrrDr r rrfrrr )r6rr7rH comparisons r/ next_towardzDecimal.next_toward s2 ud3 ? lGug. JYYu% ?>>%( (  ..)C//'*C ??   !C!$ ,   )   ) \\^gll *   +   +   )   )$$W- r1c0 |jry|jry|j}|dk(ry|dk(ry|jr|jryy| t }|j | r|jry y |jry y )Nrr r2z +Infinityrz -Infinityz-Zeroz+Zerorpz -Subnormalz +Subnormalz-Normalz+Normal)rrrrrDrr)r6r7infs r/ number_classzDecimal.number_class s  <<> <<>  !8 "9 <<>zz ? lG   W  -zz## ::r1c tdSNrrbrs r/radixz Decimal.radix s5r{r1cn | t}t|d}|j||}|r|S|jdk7r|j t S|j t|cxkr|j ksn|j t S|jr t|St|}|j}|j t|z }|dkDr d|z|z}n |dkr|| d}||d|d|z}t|j|jdxsd|jSNTrr(rrrrrrr r`rrrrErrCrDr)r6rr7rHtorotrotdigtopadrotateds r/rotatezDecimal.rotate s*C ? lGud3ug. J ::?''(89 9 U;w||;''(89 9    4= E  s6{* 19Y'F QYUFG_F.6&5>1 's 3 :sDIIG Gr1c: | t}t|d}|j||}|r|S|jdk7r|j t Sd|j |jzz}d|j |jzz}|t|cxkr|ksn|j t S|jr t|St|j|j|jt|z}|j|}|S)NTrr(rr)rrrrrr rar`rrrrCrDrEr)r6rr7rHliminflimsuprs r/scalebzDecimal.scaleb sL ? lGud3ug. J ::?''(89 9w||gll23w||gll23#e*..''(89 9    4= TZZDIIE 4J K FF7Or1c | t}t|d}|j||}|r|S|jdk7r|j t S|j t|cxkr|j ksn|j t S|jr t|St|}|j}|j t|z }|dkDr d|z|z}n |dkr|| d}|dkr|d|}n|d|zz}||j d}t|j|jdxsd|jSrbrc)r6rr7rHrdrerfshifteds r/r8z Decimal.shift"sFC ? lGud3ug. J ::?''(89 9 U;w||;''(89 9    4= E  s6{* 19Y'F QYUFG_F 19VenGs5y(Gw||mn-G $+NN3$7$>3 K Kr1c2|jt|ffSr,) __class__rrs r/ __reduce__zDecimal.__reduce__IsT --r1c\t|tur|S|jt|Sr,typerrprrs r/__copy__zDecimal.__copy__L& : K~~c$i((r1c\t|tur|S|jt|Sr,rs)r6memos r/ __deepcopy__zDecimal.__deepcopy__Qrvr1c | t}t||}|jrIt|j|}t |j }|ddk(r|dz }t|||S|dddg|j|d<|ddk(r.t|j|j|jdz}|j}|d}|i|ddvr|j|d z|}nL|dd vr|j| |}n1|dd vr*t|j|kDr|j||}|s(|jd kDr|dd vr|jd |}|s|d r|jrd } n |j} |jt|jz} |ddvr |s|d |z } n-d } n*|dd vr| } n |dd vr|jd kr| dkDr| } nd }  d krd} d| z|jz} ne| t|jkDr+|jd| t|jz zz} d} n"|jd| xsd} |j| d} | | z }t!| | | ||S)N) _localeconvrt%gGr precisioneEr2zfF%gGr(no_neg_0r rr)r_parse_format_specifierr _format_signrDrr _format_alignrgrCrErr_rr&r_format_number)r6 specifierr7r{specrQbodyr_r adjusted_signrrrrrs r/ __format__zDecimal.__format__Xs  ? lG&ykJ    D1Dt}}'DF|s"  tT2 2 < :g&6&67DL <3 #DJJ 499Q;GD##%  F|t#{{9Q;9f&}}iZ:f%#dii.9*D{{9h7 A $v,%*?==H-DZ(TZZM JJMYYTYY/ <4 I1y= &\U "!H &\T !yyA~*r/% a<GXI2H DII &ii#xDII'>"??GHii *1cGyy+H!mWhTJJr1)rN)NNr,)FN)TN)r:r;r< __slots__r classmethodrrrrrrrrrrrrrrrrr rrrr r#r+__radd__r-r/r4__rmul__r;r@rBrHrJrLrNrRrTrVr[r] __trunc__propertyr_rcrerhrFrryr{r~rrrrrdictrorrrrrrrrrrrr&rrr to_integralrr%rrrrrrrrrrrrr rrrrrrrrrr%r+rr1r3r7r<rCrHrJrGrNrPrUrWrZr]r`rhrlr8rqruryrr-r1r/rrs66I T@l**X  @B4-'@%$%$%)$(4O0d+ 2/h7!,!*,TlH B46nH9!vB8"#H764I!V/89 7I $ ZL'--+++# &**&"  <6| 2 4*/XS4jv?pVp4@2;z ' 8D.:."$KaF(!T !D%2  4FR "KO= IV$ '/  .9,20d0<1f!<  A")A"A"!<!<%.%.,\(TGB2$KN.) )TKr1rcr tjt}||_||_||_||_|Sr,)rrrrDrErr)rQ coefficientrspecialr6s r/rCrCs9 >>' "DDJDIDID Kr1c eZdZ dZdZdZy)rvc.|j|_yr,)rrr{)r6r{s r/__init__z_ContextManager.__init__s&++-r1cbt|_t|j|jSr,)r saved_contextrr{rs r/ __enter__z_ContextManager.__enter__s&'\4##$r1c.t|jyr,)rr)r6tvtbs r/__exit__z_ContextManager.__exit__s4%%&r1N)r:r;r<rrrr-r1r/rvrvs . 'r1rvceZdZ dSdZdZdZdZdZdZdZ d Z d Z d Z d Z e ZdTd ZdZdZdZdZdZdZdZdUdZdZdZdZdZdZdZdZdZdZ dZ!dZ"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/Z2d0Z3d1Z4d2Z5d3Z6d4Z7d5Z8d6Z9d7Z:d8Z;d9Zd<Z?d=Z@d>ZAd?ZBd@ZCdAZDdBZEdCZFdTdDZGdEZHdFZIdGZJdHZKdIZLdJZMdKZNdLZOdMZPdNZQdOZRdPZSdQZTdRZUeUZVy)VrNc  t} ||n  j|_||n  j|_||n  j|_||n  j |_||n  j |_||n  j|_| g|_n| |_  jj|_ n8tts!tfdtzD|_ n|_  tjtd|_ytts!tfdtzD|_y|_y#t$rYPwxYw)Nc3<K|]}|t|vfywr,r).0rZrjs r/ z#Context.__init__..!M.rr)r NameErrorr`r_rfrargrh_ignored_flagsrjrrrrrfromkeysri) r6r`r_rfrargrhrirjrdcs `` r/rzContext.__init__s"  B!,D"'' $,$8bkk  ,D"''  ,D"'' $,$8bkk #/URXX  !"$D "0D  =DJE4(MHut| !BdDRVX]E^!^__ U]t| !BdDRVX]E^!^__t|ut| !AT4QUW\D]!]^^!!$e44r1ct|tstd|z|D]}|tvs t d|ztD]}||vst d|zt j |||S)Nz%s must be a signal dictz%s is not a valid signal dict)rrryrKeyErrorrr)r6rrrs r/_set_signal_dictzContext._set_signal_dictsz!T"6:; ;C(?>BCCC!8>BCC!!$a00r1c|dk(r|j||ddS|dk(r|j||ddS|dk(r|j||ddS|dk(r|j||ddS|d k(r|j||ddS|d k(r-|tvrtd |ztj |||S|d k(s|d k(r|j ||S|dk(rtj |||St d|z)Nr`r2r\rfrr(rargrhr_z%s: invalid rounding moderirjrz.'decimal.Context' object has no attribute '%s')r_rounding_modesryrrrAttributeError)r6rrs r/rzContext.__setattr__%s& 6>**45A A V^**4B B V^**45A A Z **41= = W_**41= = Z O+ ;e CDD%%dD%8 8 W_((u5 5 % %%%dD%8 8 @4GI Ir1ctd|z)Nz%s cannot be deleted)r)r6rs r/ __delattr__zContext.__delattr__>s3d:;;r1c z|jjDcgc] \}}|s | }}}|jjDcgc] \}}|s | }}}|j|j|j |j |j|j|j||ffScc}}wcc}}wr,) rirwrjrpr`r_rfrargrh)r6sigrrirjs r/rqzContext.__reduce__Bs#'::#3#3#5;#5a#5;#'::#3#3#5;#5a#5;DMM499dii E5:; ;<;s B1B1 B7B7c g}|jdt|z|jjDcgc]\}}|s |j}}}|jddj |zdz|j jDcgc]\}}|s |j}}}|jddj |zdzdj |dzScc}}wcc}}w)NzrContext(prec=%(prec)d, rounding=%(rounding)s, Emin=%(Emin)d, Emax=%(Emax)d, capitals=%(capitals)d, clamp=%(clamp)dzflags=[, ]ztraps=[))rvarsrirwr:rrj)r6rZrrnamesrs r/r zContext.__repr__Is'  #: )- (8(8(:@(:1a(:@ TYYu--34(, (8(8(:@(:1a(:@ TYYu--34yy|c!! A@s C3 C3 C9(C9cF |jD]}d|j|<yra)rir6flags r/rszContext.clear_flagsV!%JJD DJJt r1cF |jD]}d|j|<yra)rjrs r/ clear_trapszContext.clear_traps[rr1c  t|j|j|j|j|j |j |j|j|j }|Sr,) rr`r_rfrargrhrirjrr6ncs r/rzContext._shallow_copy`sP/ TYY tyy$))]]DJJ DJJ((* r1c  t|j|j|j|j|j |j |jj|jj|j }|Sr,) rr`r_rfrargrhrirrrjrrs r/rrz Context.copygs_, TYY tyy$))]]DJJZZ__& (9((* r1c tj||}||jvr|j|g|Sd|j|<|j |s|j|g|S||r)_condition_maprmrr8rirj)r6 condition explanationr.errors r/rzContext._raise_errorps ""9i8 D'' '!57>>$.. . 5zz% %9;%%d2T2 2K  r1c* |jtSr,) _ignore_flagsrrs r/rRzContext._ignore_all_flagss2!t!!8,,r1cT |jt|z|_t|Sr,)rr)r6ris r/rzContext._ignore_flagss(2 $22T%[@E{r1c |rt|dttfr|d}|D]}|jj |yra)rrrrremove)r6rirs r/ _regard_flagszContext._regard_flagss@9 Za5,7!HED    & &t ,r1cN t|j|jz dzSr)rrfr`rs r/r6z Context.Etinys"/499tyy(1,--r1cN t|j|jz dzSr)rrar`rs r/rnz Context.Etops":499tyy(1,--r1c. |j}||_|Sr,)r_)r6rtr_s r/rzContext._set_roundings == r1cd t|tr-||jk7sd|vr|jtdSt ||}|j rEt|j|j|jz kDr|jtdS|j|S)NrzAtrailing or leading whitespace and underscores are not permitted.rpzdiagnostic info too long in NaN) rrrrrrrrrEr`rhr)r6r#rs r/create_decimalzContext.create_decimals & c3 SCIIK%73#:$$%5&FG G C & 88:#aff+ DJJ(>>$$%5%FH Hvvd|r1cP tj|}|j|Sr,)rrr)r6rrs r/create_decimal_from_floatz!Context.create_decimal_from_floats'    q !vvd|r1cB t|d}|j|Sr)rr#r6rs r/rz Context.abss& " 1d +yyy&&r1ct t|d}|j||}|turtd|z|SNTrrpUnable to convert %s to Decimal)rr+rryr6rrBr?s r/addz Context.addsE  1d + IIaI &  =AB BHr1c6t|j|Sr,)rrrs r/_applyzContext._applys166$<  r1cZ t|ts td|jS)Nz,canonical requires a Decimal as an argument.)rrryrrs r/rzContext.canonicals+ !W%JK K{{}r1cD t|d}|j||Sr)rrr6rrBs r/rzContext.compares) @ 1d +yyDy))r1cD t|d}|j||Sr)rrrs r/rzContext.compare_signal7s+ > 1d +400r1c@ t|d}|j|Sr)rrrs r/rzContext.compare_totalZs$ 2 1d +q!!r1c@ t|d}|j|Sr)rrrs r/rzContext.compare_total_magws&  1d +""1%%r1c> t|d}|jSr)rrrs r/rzContext.copy_abss!  1d +zz|r1c4 t|d}t|Sr)rrrs r/ copy_decimalzContext.copy_decimals  1d +qzr1c> t|d}|jSr)rrrs r/rzContext.copy_negates!  1d +}}r1c@ t|d}|j|Sr)rrrs r/rzContext.copy_signs# ( 1d +{{1~r1ct t|d}|j||}|turtd|z|Sr)rr;rryrs r/dividezContext.dividesE : 1d + MM!TM *  =AB BHr1ct t|d}|j||}|turtd|z|Sr)rrTrryrs r/ divide_intzContext.divide_intsE  1d + NN1dN +  =AB BHr1ct t|d}|j||}|turtd|z|Sr)rrHrryrs r/r7zContext.divmodsE  1d + LLDL )  =AB BHr1cB t|d}|j|Sr)rrrs r/rz Context.exps& ( !T *uuTu""r1cF t|d}|j|||Sr)rr)r6rrBrs r/rz Context.fma's* & 1d +uuQ4u((r1cZ t|ts td|jS)Nz/is_canonical requires a Decimal as an argument.)rrryr rs r/r zContext.is_canonical>s, !W%MN N~~r1c> t|d}|jSr)rrrs r/rzContext.is_finiteKs! $ 1d +{{}r1c> t|d}|jSr)rrrs r/rzContext.is_infiniteas!  1d +}}r1c> t|d}|jSr)rrrs r/rzContext.is_nanps!  1d +xxzr1cB t|d}|j|Sr)rrrs r/rzContext.is_normals& & 1d +{{4{((r1c> t|d}|jSr)rrrs r/rzContext.is_qnans!  1d +yy{r1c> t|d}|jSr)rrrs r/rzContext.is_signeds!  1d +{{}r1c> t|d}|jSr)rrrs r/rzContext.is_snans!  1d +yy{r1cB t|d}|j|Sr)rrrs r/rzContext.is_subnormals& $ 1d +~~d~++r1c> t|d}|jSr)rrrs r/rzContext.is_zeros!  1d +yy{r1cB t|d}|j|Sr)rr+rs r/r+z Context.lns& $ 1d +ttDt!!r1cB t|d}|j|Sr)rr1rs r/r1z Context.log10s& 0 1d +wwtw$$r1cB t|d}|j|Sr)rr3rs r/r3z Context.logb s& , 1d +vvdv##r1cD t|d}|j||Sr)rrCrs r/rCzContext.logical_and:( . 1d +}}Q}--r1cB t|d}|j|Sr)rrHrs r/rHzContext.logical_invertUs)  1d +--r1cD t|d}|j||Sr)rrJrs r/rJzContext.logical_orhs( . 1d +||At|,,r1cD t|d}|j||Sr)rrGrs r/rGzContext.logical_xorr r1cD t|d}|j||Sr)rr%rs r/r%z Context.max( . 1d +uuQu%%r1cD t|d}|j||Sr)rrNrs r/rNzContext.max_mag(  1d +yyDy))r1cD t|d}|j||Sr)rrrs r/rz Context.minrr1cD t|d}|j||Sr)rrPrs r/rPzContext.min_magrr1cB t|d}|j|Sr)rrrs r/minusz Context.minus&  1d +yyy&&r1ct t|d}|j||}|turtd|z|Sr)rr4rryrs r/multiplyzContext.multiplysE 0 1d + IIaI &  =AB BHr1cB t|d}|j|Sr)rrUrs r/rUzContext.next_minus's& 1d +||D|))r1cB t|d}|j|Sr)rrWrs r/rWzContext.next_plus;s& 1d +{{4{((r1cD t|d}|j||Sr)rrZrs r/rZzContext.next_towardOs( > 1d +}}Q}--r1cB t|d}|j|Sr)rrrs r/rzContext.normalizers& ( 1d +{{4{((r1cB t|d}|j|Sr)rr]rs r/r]zContext.number_classs'- \ 1d +~~d~++r1cB t|d}|j|Sr)rr rs r/plusz Context.plusrr1cv t|d}|j|||}|turtd|z|Sr)rrrry)r6rrBrr?s r/powerz Context.powersIG P 1d + IIaI .  =AB BHr1cD t|d}|j||Sr)rrrs r/rzContext.quantizes)5 l 1d +zz!Tz**r1c tdSr_rbrs r/r`z Context.radixWs r{r1ct t|d}|j||}|turtd|z|Sr)rrLrryrs r/r9zContext.remainder_sE < 1d + IIaI &  =AB BHr1cD t|d}|j||Sr)rrRrs r/rRzContext.remainder_nears+ < 1d +400r1cD t|d}|j||Sr)rrhrs r/rhzContext.rotates( 2 1d +xx4x((r1c@ t|d}|j|Sr)rrrs r/rzContext.same_quantums$ ( 1d +~~a  r1cD t|d}|j||Sr)rrlrs r/rlzContext.scalebs(  1d +xx4x((r1cD t|d}|j||Sr)rr8rs r/r8z Context.shifts( 4 1d +wwq$w''r1cB t|d}|j|Sr)rrrs r/rz Context.sqrt s& 8 1d +vvdv##r1ct t|d}|j||}|turtd|z|Sr)rr-rryrs r/subtractzContext.subtract-sE  1d + IIaI &  =AB BHr1cB t|d}|j|Sr)rrrs r/rzContext.to_eng_stringDs& 0 1d +t,,r1cB t|d}|j|Sr)rrrs r/ to_sci_stringzContext.to_sci_string`s&  1d +yyy&&r1cB t|d}|j|Sr)rrrs r/rzContext.to_integral_exacths) 4 1d +""4"00r1cB t|d}|j|Sr)rrrs r/rzContext.to_integral_values) 2 1d +""4"00r1) NNNNNNNNNr,)r)Wr:r;r<rrrrrrqr rsrrrrrurrRrrrr6rnrrrrrrrrrrrrrrrrrr7rrr rrrrrrrrrr+r1r3rCrHrJrGr%rNrrPrrrUrWrZrr]r r"rr`r9rRrhrrlr8rr-rr0rrrr-r1r/rrs$BFDH&*"H 5 1I2<; "! ! H!,--H..&"$'**! "*H!1F":&   0#J.*#0).  ,  ). " ,,"",%8$4.6.&-6.6&6*"&6*"'"@*()(!.F)00,d'"N`8+t$L 1D):!0)&(<$@.-8'1<1<$Kr1rceZdZdZddZdZy)rrQrrNc |d|_d|_d|_yt|tr=|j |_t|j |_|j|_y|d|_|d|_|d|_y)Nr(r2r)rQrrrrrDrEr)r6rs r/rz_WorkRep.__init__sn =DIDHDH w ' DI5::DHzzDHaDIQxDHQxDHr1cVd|jd|jd|jdS)N(rrr4rs r/r z_WorkRep.__repr__s!%DHHdhh??r1r,)r:r;r<rrr r-r1r/rrs$I  @r1rc |j|jkr|}|}n|}|}tt|j}tt|j}|jt d||z dz z}||jzdz |krd|_||_|xjd|j|jz zzc_|j|_||fS)Nrrr2r)rrrrr)r)r*r`tmprtmp_len other_lenrs r/r'r's ww#cgg,GC N#I ''CGdNQ./ /C599q 3&  GGrcgg )**GiiCG 8Or1c |dk(ry|dk\r|d|zzStt|}t|t|jdz }|| krdS|d| zzS)Nr(rr)rrrrstrip)rBrstr_nval_ns r/rrsp  Av a2q5yCF E Sc!233rzt2qBF{2r1ch |dks|dkr tdd}||k7r||| |zz dz }}||k7r|S)Nr(z3Both arguments to _sqrt_nearest should be positive.r2)r)rBrrBs r/ _sqrt_nearestrAsS  AvaNOOA q&!QBE'1*1 q& Hr1cF d|z||z }}|d||dz zz|dzz|kDzS)Nr2rr-)rr8rBr>s r/_rshift_nearestrCs? :qEzqA 1!9 1%) **r1cD t||\}}|d|z|dzz|kDzS)Nrr2)r7)rrBr>r?s r/ _div_nearestrE s3 !Q%Q}QuW'=%=r5yIII   E)3 //r1ceZdZ dZdZy) _Log10Memoizecd|_y)N/23025850929940456840179914546843642076011014886)rrs r/rz_Log10Memoize.__init__s G r1cB |dkr td|t|jk\r\d} d||zdzz}tt t d|z|d}|| dd|zk7rn|dz }@|j ddd|_t|jd|d zS) Nr(zp should be nonnegativerrrrrrr2)rrrrrErNr=r)r6rrrHrs r/ getdigitsz_Log10Memoize.getdigitss  q567 7 DKK E5O\%1a.#>?5&'?c%i/  !--,Sb1DK4;;t!$%%r1N)r:r;r<rr\r-r1r/rXrXsCH&r1rXcR t||z|z}tdtt|zd|zz }t ||}||z}t |dz ddD]}t |||zz||z}t |dz ddD]}||dzz}t |||zz|}||zS)NrGrr2r(rr)rrrrrEr) rrHrIrJrKrMshiftrrs r/_iexpr_s!( 1qyA SSV_qs # $$AQA TF 1Q32  FQJ! 41Q3B QqS AfHv .  Q3Jr1c ( |dz }td|tt|zdz }||z}||z}|dk\r |d|zz}n |d| zz}t|t |\}}t |d|z}t t |d|zd||z dzfS)Nrr(r2rir)r%rrr7rQrEr_) rrrrr>r8cshiftquotrs r/r r s 4FA 1s3q6{?Q& 'E E A aCE z2u9BJv}Q/0ID# sBI &C c2q5)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)rrrr)rEr ) rrrrrrBlxcr8pcrrs r/rrs  CBLBA B!A C qDE z VBI  #b&"uf* - QwR\B ! #a 0ac1ac3E #: Qq1"3E #: 21vqs+ sUB' q #:r1rF5(r rr) r12345678r^ch |dkr tdt|}dt|z||dz S)Nr(z0The argument to _log10_lb should be nonnegative.r)rrr)r correctionstr_cs r/rr*s@KAvKLL FE s5z>JuQx0 00r1c t|tr|St|tr t|S|r%t|trtj |S|rt d|zt S)Nr)rrrrrryr)rr allow_floats r/rr5sc%! %u~z%/!!%((9EABB r1cz t|tr||fSt|tjrm|jsJt |j tt|j|jz|j}|t|jfS|r5t|tjr|jdk(r |j}t|t rMt#}|rd|j$t&<n|j)t&d|tj+|fSt,t,fS)Nr(r2r)rr_numbersRationalrrCrDrrrE denominatorr numeratorComplexrcr_rrrirrrr)r6rrr7s r/rrHs %!U{ %**+#DJJ$'DII9J9J(J$K$(II/DWU__--- z%)9)9:uzzQ %, ,-GMM. )  M OW''... > ))r1ri?Bi)r`r_rjrirarfrgrhr)r`r_rjria # A numeric string consists of: # \s* (?P[-+])? # an optional sign, followed by either... ( (?=\d|\.\d) # ...a number (with at least one digit) (?P\d*) # having a (possibly empty) integer part (\.(?P\d*))? # followed by an optional fractional part (E(?P[-+]?\d+))? # followed by an optional exponent, or... | Inf(inity)? # ...an infinity, or... | (?Ps)? # ...an (optionally signaling) NaN # NaN (?P\d*) # with (possibly empty) diagnostic info. ) # \s* \Z z0*$z50*$z\A (?: (?P.)? (?P[<>=^]) )? (?P[-+ ])? (?Pz)? (?P\#)? (?P0)? (?P(?!0)\d+)? (?P,)? (?:\.(?P0|(?!0)\d+))? (?P[eEfFgGn%])? \Z cp tj|}|td|z|j}|d}|d}|ddu|d<|dr |td|z|td|z|xsd|d<|xsd|d<|d d |d <t |d xsd |d <|d t |d |d <|d dk(r|d|ddvrd|d <|ddk(rHd|d<|t j }|dtd|z|d|d<|d|d<|d|d<|S|dd|d<ddg|d<d|d<|S)NzInvalid format specifier: fillalignzeropadz7Fill character conflicts with '0' in format specifier: z2Alignment conflicts with '0' in format specifier:  >rQr minimumwidthrrr(rtgGnr2rBr} thousands_sepzJExplicit thousands separator conflicts with 'n' type in format specifier: grouping decimal_pointrrr)_parse_format_specifier_regexmatchr groupdictr_locale localeconv) format_specr{r format_dictr~rs r/rrs$ &++K8Ay5 CDD++-K v D  E))4D@K 9  68CDE E  24?@A A+#K!@KLM 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 ) Nrr~r M788r1c ddlm}m}|sgS|ddk(r#t|dk\r||dd||dS|dtj k(r|ddSt d)Nr()chainrepeatrrrz unrecognised format for grouping) itertoolsrrrrCHAR_MAXr)rrrs r/_group_lengthsrAsq(  " s8}1Xcr]F8B<$899 ")) )};<? ? CKA. 2 c1s6{?+faRSk9:!Q )q. SX & F Y * c1s6{?+faRSk9: 88HV$ %%r1c$ |ry|ddvr|dSy)NrrQz +rr-) is_negativers r/rr}s$# f F|r1c4 t||}|s|dr|d|z}|dk7s|ddvr"ddddd|d}|d j||z }|dd k(r|d z }|d r|d t|z t|z }nd}t|||}t |||z|S) Naltrr(rtrrr)rrr~r}z{0}{1:+}r|rr)rformatrrr)rrrrrrQecharrs r/rrs"  T *D4;(83 ax4<4'#C8fFJ%%eS11 F|sC I(3x=83t9D  #GT9=G wx/ 66r1Infz-Infr rrr,)F)r()r)FF)r2){__all__r: __xname__ __version____libmpdec_version__mathrnumbersrxsys collectionsr) _namedtupler ImportErrorrrrrrrrrr%r&maxsizer!r"r#r$ArithmeticErrorrr r rZeroDivisionErrorr rrr rr rrrryrrrr contextvars ContextVarrl frozensetrxrrr rrrCNumberregisterrvrrr'rrrrrArCrErNr0r)rXr\rQr_r rrrrrrrrecompileVERBOSE IGNORECASErrrwrDOTALLrlocalerrrrrrrr(r'rGrrrrO hash_infomodulusrr\rrX _PyHASH_NANrrr-r1r/rs '! F    &5~/EiXL   #  #   ;;'!H!H"HHHH  #   .  ':'%%'8% )  (*;    %     #:w#:L )  %y  ^Wh 'N D##3$%5#$4 !13 }o}/:G-{--.?@O &+hB4KfB4KHh& ! 'f 'O$fO$b6@v@4< 3*  +!. ` 1D*0X!&F!&F)) #J"?H(Vr" br+1&"*T /x)9:   x)97IN  * "**"ZZ"--# !""'#&RZZ  $ $ bjj && !+ ,ZZ !   N`6=.#&J#7R EN FOu~ qzr{ /0--''mm mm B!+_= CD&%L&b|  s#M%M4%M10M14M<;M<