Your IP : 18.225.209.237


Current Path : /opt/alt/python313/lib64/python3.13/__pycache__/
Upload File :
Current File : //opt/alt/python313/lib64/python3.13/__pycache__/_pydecimal.cpython-313.pyc

�

*}g�w���Sr/SQr\rSrSrSrSSKrSSKr	SSK
r
SSKJr
 \
"SS	SS
9rSrS
rSrSrSrSrSrSrSrSr\
R4S:XaSrSrSrOSrSrSr\\S-
-
r"SS\5r "SS\ 5r!"SS \ 5r""S!S"\"5r#"S#S$\ \$5r%"S%S&\"5r&"S'S(\"\$5r'"S)S*\ 5r("S+S,\"5r)"S-S.\ 5r*"S/S0\ 5r+"S1S2\(\*5r,"S3S4\(\*\+5r-"S5S6\ \.5r/\!\%\(\,\*\-\"\+\//	r0\#\"\&\"\'\"\)\"0r1\\\\\\\\4r2SSK3r3\3Rh"S75r5\6"/S8Q5r7S9r8S:r9C3StS;jr:"S<S=\;5r<SuS>jr=\	R|R\<5 "S?S@\;5r@"SASB\;5rA"SCSD\;5rBSvSEjrC\DR�rFSFrGSGrHSHrISIrJSwSJjrKSKrLSLrM"SMSN\;5rN\N"5R�rPSwSOjrQSPrRSQrSSRSSSTSUSVSWSXSYSZS[.	4S\jrTSxS]jrUSuS^jrV\A"S_\\%\,\"//S`SaSSSb9rW\A"Sc\\%\,\"\!\-//Sd9rX\A"Sc\//Sd9rYSSKZrZ\ZR�"Se\ZR�\ZR�-5R�r_\ZR�"Sf5R�r`\ZR�"Sg5R�ra\ZR�"Sh\ZR�\ZR�-5rcCZSSKdreStSijrfSjrgSkrhSySljriSmrjSnrk\<"So5rl\<"Sp5rm\<"Sq5rn\<"S5ro\<"S5rp\<"Sr5rq\l\m4rr\
R�R�ru\
R�R�rw\
R�R�ry\z"SY\uSs-
\u5r{C
g!\a SrGNGf=f!\a N�f=f)zz Python decimal arithmetic module)%�Decimal�Context�DecimalTuple�DefaultContext�BasicContext�ExtendedContext�DecimalException�Clamped�InvalidOperation�DivisionByZero�Inexact�Rounded�	Subnormal�Overflow�	Underflow�FloatOperation�DivisionImpossible�InvalidContext�ConversionSyntax�DivisionUndefined�
ROUND_DOWN�
ROUND_HALF_UP�ROUND_HALF_EVEN�
ROUND_CEILING�ROUND_FLOOR�ROUND_UP�ROUND_HALF_DOWN�
ROUND_05UP�
setcontext�
getcontext�localcontext�MAX_PREC�MAX_EMAX�MIN_EMIN�	MIN_ETINY�HAVE_THREADS�HAVE_CONTEXTVAR�decimalz1.70z2.4.2�N)�
namedtuplerzsign digits exponent)�modulec��U$�N�)�argss �1/opt/alt/python313/lib64/python3.13/_pydecimal.py�<lambda>r0Cs���rrrrrrrrTl����l��N�Zol������N�Zoi@�Ti����c��\rSrSrSrSrSrg)r�_a�Base exception class.

Used exceptions derive from this.
If an exception derives from another exception besides this (such as
Underflow (Inexact, Rounded, Subnormal) that indicates that it is only
called if the others are present.  This isn't actually used for
anything, though.

handle  -- Called when context._raise_error is called and the
           trap_enabler is not set.  First argument is self, second is the
           context.  More arguments can be given, those being after
           the explanation in _raise_error (For example,
           context._raise_error(NewError, '(-x)!', self._sign) would
           call NewError().handle(context, self._sign).)

To define a new exception, it should be sufficient to have it derive
from DecimalException.
c��gr,r-��self�contextr.s   r/�handle�DecimalException.handlers��r1r-N��__name__�
__module__�__qualname__�__firstlineno__�__doc__r9�__static_attributes__r-r1r/rr_s���$
r1rc��\rSrSrSrSrg)r	�va	Exponent of a 0 changed to fit bounds.

This occurs and signals clamped if the exponent of a result has been
altered in order to fit the constraints of a specific concrete
representation.  This may occur when the exponent of a zero result would
be outside the bounds of a representation, or when a large normal
number would have an encoded exponent that cannot be represented.  In
this latter case, the exponent is reduced to fit and the corresponding
number of zero digits are appended to the coefficient ("fold-down").
r-N�r<r=r>r?r@rAr-r1r/r	r	v���	r1r	c��\rSrSrSrSrSrg)r
�a�An invalid operation was performed.

Various bad things cause this:

Something creates a signaling NaN
-INF + INF
0 * (+-)INF
(+-)INF / (+-)INF
x % 0
(+-)INF % x
x._rescale( non-integer )
sqrt(-x) , x > 0
0 ** 0
x ** (non-integer)
x ** (+-)INF
An operand is invalid

The result of the operation after these is a quiet positive NaN,
except when the cause is a signaling NaN, in which case the result is
also a quiet NaN, but with the original sign, and an optional
diagnostic information.
c��U(a9[USRUSRSS5nURU5$[$)Nr(�nT)�_dec_from_triple�_sign�_int�_fix_nan�_NaN)r7r8r.�anss    r/r9�InvalidOperation.handle�s9���"�4��7�=�=�$�q�'�,�,��T�J�C��<�<��(�(��r1r-Nr;r-r1r/r
r
�s���,r1r
c��\rSrSrSrSrSrg)r�z�Trying to convert badly formed string.

This occurs and signals invalid-operation if a string is being
converted to a number and it does not conform to the numeric string
syntax.  The result is [0,qNaN].
c��[$r,�rNr6s   r/r9�ConversionSyntax.handle�����r1r-Nr;r-r1r/rr�s���r1rc��\rSrSrSrSrSrg)r�a�Division by 0.

This occurs and signals division-by-zero if division of a finite number
by zero was attempted (during a divide-integer or divide operation, or a
power operation with negative right-hand operand), and the dividend was
not zero.

The result of the operation is [sign,inf], where sign is the exclusive
or of the signs of the operands for divide, or is 1 for an odd power of
-0, for power.
c��[U$r,)�_SignedInfinity�r7r8�signr.s    r/r9�DivisionByZero.handle�s
���t�$�$r1r-Nr;r-r1r/rr�s��
�%r1rc��\rSrSrSrSrSrg)r�z�Cannot perform the division adequately.

This occurs and signals invalid-operation if the integer result of a
divide-integer or remainder operation had too many digits (would be
longer than precision).  The result is [0,qNaN].
c��[$r,rTr6s   r/r9�DivisionImpossible.handle�rVr1r-Nr;r-r1r/rr�����r1rc��\rSrSrSrSrSrg)r��z�Undefined result of division.

This occurs and signals invalid-operation if division by zero was
attempted (during a divide-integer, divide, or remainder operation), and
the dividend is also zero.  The result is [0,qNaN].
c��[$r,rTr6s   r/r9�DivisionUndefined.handle�rVr1r-Nr;r-r1r/rr�rbr1rc��\rSrSrSrSrg)r��a�Had to round, losing information.

This occurs and signals inexact whenever the result of an operation is
not exact (that is, it needed to be rounded and any discarded digits
were non-zero), or if an overflow or underflow condition occurs.  The
result in all cases is unchanged.

The inexact signal may be tested (or trapped) to determine if a given
operation (or sequence of operations) was inexact.
r-NrDr-r1r/rr�rEr1rc��\rSrSrSrSrSrg)r��a�Invalid context.  Unknown rounding, for example.

This occurs and signals invalid-operation if an invalid context was
detected during an operation.  This can occur if contexts are not checked
on creation and either the precision exceeds the capability of the
underlying concrete representation or an unknown or unsupported rounding
was specified.  These aspects of the context need only be checked when
the values are required to be used.  The result is [0,qNaN].
c��[$r,rTr6s   r/r9�InvalidContext.handle�rVr1r-Nr;r-r1r/rr�s���r1rc��\rSrSrSrSrg)r
��a�Number got rounded (not  necessarily changed during rounding).

This occurs and signals rounded whenever the result of an operation is
rounded (that is, some zero or non-zero digits were discarded from the
coefficient), or if an overflow or underflow condition occurs.  The
result in all cases is unchanged.

The rounded signal may be tested (or trapped) to determine if a given
operation (or sequence of operations) caused a loss of precision.
r-NrDr-r1r/r
r
�rEr1r
c��\rSrSrSrSrg)r�a�Exponent < Emin before rounding.

This occurs and signals subnormal whenever the result of a conversion or
operation is subnormal (that is, its adjusted exponent is less than
Emin, before any rounding).  The result in all cases is unchanged.

The subnormal signal may be tested (or trapped) to determine if a given
or operation (or sequence of operations) yielded a subnormal result.
r-NrDr-r1r/rr�s��r1rc��\rSrSrSrSrSrg)r�a�Numerical overflow.

This occurs and signals overflow if the adjusted exponent of a result
(from a conversion or from an operation that is not an attempt to divide
by zero), after rounding, would be greater than the largest value that
can be handled by the implementation (the value Emax).

The result depends on the rounding mode:

For round-half-up and round-half-even (and for round-half-down and
round-up, if implemented), the result of the operation is [sign,inf],
where sign is the sign of the intermediate result.  For round-down, the
result is the largest finite number that can be represented in the
current precision, with the sign of the intermediate result.  For
round-ceiling, the result is the same as for round-down if the sign of
the intermediate result is 1, or is [0,inf] otherwise.  For round-floor,
the result is the same as for round-down if the sign of the intermediate
result is 0, or is [1,inf] otherwise.  In all cases, Inexact and Rounded
will also be raised.
c��UR[[[[4;a	[
U$US:XaQUR[:Xa	[
U$[USUR-URUR-
S-5$US:XaQUR[:Xa	[
U$[USUR-URUR-
S-5$g)Nr(�9r2)�roundingrrrrrZrrJ�prec�Emaxrr[s    r/r9�Overflow.handles������
�� /�� ;�;�"�4�(�(��1�9����=�0�&�t�,�,�#�D�#�g�l�l�*:�#�L�L����5�a�7�9�
9��1�9����;�.�&�t�,�,�#�D�#�g�l�l�*:�$�\�\�'�,�,�6�q�8�:�
:�r1r-Nr;r-r1r/rrs���*
:r1rc��\rSrSrSrSrg)ri&aTNumerical underflow with result rounded to 0.

This occurs and signals underflow if a result is inexact and the
adjusted exponent of the result would be smaller (more negative) than
the smallest value that can be handled by the implementation (the value
Emin).  That is, the result is both inexact and subnormal.

The result after an underflow will be a subnormal number rounded, if
necessary, so that its exponent is not less than Etiny.  This may result
in 0 with the sign of the intermediate result and an exponent of Etiny.

In all cases, Inexact, Rounded, and Subnormal will also be raised.
r-NrDr-r1r/rr&���r1rc��\rSrSrSrSrg)ri5atEnable stricter semantics for mixing floats and Decimals.

If the signal is not trapped (default), mixing floats and Decimals is
permitted in the Decimal() constructor, context.create_decimal() and
all comparison operators. Both conversion and comparisons are exact.
Any occurrence of a mixed operation is silently recorded by setting
FloatOperation in the context flags.  Explicit conversions with
Decimal.from_float() or context.create_decimal_from_float() do not
set the flag.

Otherwise (the signal is trapped), only equality comparisons and explicit
conversions are silent. All other mixed operations raise FloatOperation.
r-NrDr-r1r/rr5rzr1r�decimal_context)rv�Eminrw�capitals�clampru�flags�trapsc��[R5$![a$ [5n[R	U5 Us$f=f)z�Returns this thread's context.

If this thread does not yet have a context, returns
a new context and sets this thread's context.
New contexts are copies of DefaultContext.
)�_current_context_var�get�LookupErrorr�set�r8s r/rr_s?���#�'�'�)�)�����)��� � ��)����s��+A�Ac��U[[[4;a UR5nUR	5 [
R
U5 g)z%Set this thread's context to context.N)rrr�copy�clear_flagsr�r�r�s r/rrms6���>�<��A�A��,�,�.���������W�%r1c���Uc
[5n[U5nUR5H4up4U[;a[	SUS35e[URX45 M6 U$)a�Return a context manager for a copy of the supplied context

Uses a copy of the current context if no context is specified
The returned context manager creates a local decimal context
in a with statement:
    def sin(x):
         with localcontext() as ctx:
             ctx.prec += 2
             # Rest of sin calculation algorithm
             # uses a precision 2 greater than normal
         return +s  # Convert result to normal precision

     def sin(x):
         with localcontext(ExtendedContext):
             # Rest of sin calculation algorithm
             # uses the Extended Context from the
             # General Decimal Arithmetic Specification
         return +s  # Convert result to normal context

>>> setcontext(DefaultContext)
>>> print(getcontext().prec)
28
>>> with localcontext():
...     ctx = getcontext()
...     ctx.prec += 2
...     print(ctx.prec)
...
30
>>> with localcontext(ExtendedContext):
...     print(getcontext().prec)
...
9
>>> print(getcontext().prec)
28
�'z2' is an invalid keyword argument for this function)r�_ContextManager�items�_context_attributes�	TypeError�setattr�new_context)�ctx�kwargs�ctx_manager�key�values     r/r r vsc��H�{��l��!�#�&�K��l�l�n�
���)�)��a��u�$V�W�X�X���'�'��4�%��r1c��\rSrSrSrSrS|Sjr\S5rSr	Sr
S}S	jrS
rSr
SrS~S
jrS~SjrS~SjrS~SjrS~SjrS~SjrSrSrSrSrSSjrS~SjrS~SjrS~SjrS�SjrS~Sjr\rS~Sjr S~Sjr!S~Sjr"\"r#S~S jr$S!r%S~S"jr&S~S#jr'S~S$jr(S~S%jr)S~S&jr*S~S'jr+S~S(jr,S~S)jr-S*r.S+r/\/r0\1S,5r2\1S-5r3S.r4S/r5S0r6S1r7S2r8S3r9S4r:S5r;S6r<S7r=S8r>S9r?\@"\8\9\:\;\<\=\>\?S:9rAS~S;jrBS<rCS=rDS~S>jrES~S?jrFS@rGS}SAjrHS~SBjrIS~SCjrJS}SDjrKS~SEjrLSFrMSGrNS}SHjrOS}SIjrP\PrQS~SJjrRS~SKjrSS~SLjrTSMrUSNrVSOrWSPrXS~SQjrYS~SRjrZS~SSjr[STr\SUr]S~SVjr^S~SWjr_SXr`SYraSZrbS[rcS~S\jrdS]reS^rfS_rgS~S`jrhSariSbrjS~ScjrkSdrlS~SejrmS~SfjrnSgroShrpS~SijrqS~SjjrrS~SkjrsS~SljrtS~SmjruS~SnjrvS~SojrwS~SpjrxS~SqjryS~SrjrzSsr{S~Stjr|S~Sujr}S~Svjr~SwrSxr�Syr�S}Szjr�S{r�g)�ri�z,Floating-point class for decimal arithmetic.)�_exprLrK�_is_specialNc��	�[RU5n[U[5(Ga�[	UR5R
SS55nUc&Uc
[5nUR[SU-5$URS5S:XaSUlOSUlURS5nUbtURS	5=(d Sn[URS
5=(d S5n[[XV-55Ul
U[U5-
UlSUlU$URS
5nUbW[[U=(d S55R#S5Ul
URS5(aSUlOSUlOSUl
SUlSUlU$[U[5(a>US:�aSUlOSUlSUl[[%U55Ul
SUlU$[U[&5(aFURUlURUlURUl
UR UlU$[U[(5(aNUR*Ul[UR5Ul
[UR,5UlSUlU$[U[.[045(Gau[U5S:wa[3S5e[US[5(a	USS;d[3S5eUSUlUSS:XaSUl
USUlSUlU$/n	USHSn
[U
[5(a2SU
s=::aS::a%O O"U	(dU
S:waU	R5U
5 MHMJ[3S5e USS;a7SR7[9[U	55Ul
USUlSUlU$[US[5(aASR7[9[U	=(d S/55Ul
USUlSUlU$[3S5e[U[:5(a~Uc
[5nUR[<S5 [&R?U5nURUlURUlURUl
UR UlU$[ASU-5e)a�Create a decimal point instance.

>>> Decimal('3.14')              # string input
Decimal('3.14')
>>> Decimal((0, (3, 1, 4), -2))  # tuple (sign, digit_tuple, exponent)
Decimal('3.14')
>>> Decimal(314)                 # int
Decimal('314')
>>> Decimal(Decimal(314))        # another decimal instance
Decimal('314')
>>> Decimal('  3.14  \n')        # leading and trailing whitespace okay
Decimal('3.14')
�_�zInvalid literal for Decimal: %rr\�-r2r(�int�frac�exp�0F�diag�signal�NrI�FT�ztInvalid tuple size in creation of Decimal from list or tuple.  The list or tuple should have exactly three elements.�r(r2z|Invalid sign.  The first value in the tuple should be an integer; either 0 for a positive number or 1 for a negative number.��	zTThe second value in the tuple must be composed of integers in the range 0 through 9.�rIr�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�grouprKr�rL�lenr�r��lstrip�absr�_WorkRepr\r��list�tuple�
ValueError�append�join�map�floatr�
from_floatr�)�clsr�r8r7�m�intpart�fracpartr�r��digits�digits           r/r��Decimal.__new__�sY��.�~�~�c�"���e�S�!�!�����
�-�-�c�2�6�7�A��y��?�(�l�G��+�+�,<� A�E� I�K�K��w�w�v��#�%���
���
��g�g�e�n�G��"��7�7�6�?�0�b���!�'�'�%�.�/�C�0����G�$4� 5�6��	��#�h�-�/��	�#(�� ��K��w�w�v����#� #�C����$4� 5� <� <�S� A�D�I��w�w�x�(�(�$'��	�$'��	�!$�D�I� #�D�I�#'�� ��K��e�S�!�!���z���
���
��D�I��C��J��D�I�$�D���K��e�W�%�%����D�I����D�J����D�I� %� 1� 1�D���K��e�X�&�&����D�J��E�I�I��D�I��E�I�I��D�I�$�D���K��e�d�5�\�*�*��5�z�Q�� �"G�H�H��u�Q�x��-�-�%��(�e�2C� �"O�P�P��q��D�J��Q�x�3����	�!�!�H��	�#'�� �6�K�1��"�1�X�E�!�%��-�-�!�u�/��/�!�U�a�Z�"�M�M�%�0�&0�)�*8�9�9�
&���8�z�)� "����C��(8� 9�D�I� %�a��D�I�'+�D�$��K� ��a��#�.�.� "����C���A�3�(?� @�D�I� %�a��D�I�',�D�$�
�K�%�&>�?�?�
�e�U�#�#���$�,��� � ���
��&�&�u�-�E����D�I����D�J����D�I� %� 1� 1�D���K��6��>�?�?r1c�<�[U[5(a!US:�aSOSnSn[[U55nO�[U[5(a�[
R"U5(d[
R"U5(aU"[U55$[
R"SU5S:XaSnOSn[U5R5upVUR5S-
n[USU--5nO[S5e[X$U*5nU[LaU$U"U5$)a�Converts a float to a decimal number, exactly.

Note that Decimal.from_float(0.1) is not the same as Decimal('0.1').
Since 0.1 is not exactly representable in binary floating point, the
value is stored as the nearest representable value which is
0x1.999999999999ap-4.  The exact equivalent of the value in decimal
is 0.1000000000000000055511151231257827021181583404541015625.

>>> Decimal.from_float(0.1)
Decimal('0.1000000000000000055511151231257827021181583404541015625')
>>> Decimal.from_float(float('nan'))
Decimal('NaN')
>>> Decimal.from_float(float('inf'))
Decimal('Infinity')
>>> Decimal.from_float(-float('inf'))
Decimal('-Infinity')
>>> Decimal.from_float(-0.0)
Decimal('-0')

r(r2g�?�zargument must be int or float.)r�r�r�r�r��_math�isinf�isnan�repr�copysign�as_integer_ratio�
bit_lengthr�rJr)r��fr\�k�coeffrI�d�results        r/r��Decimal.from_floatIs���,�a�����Q��1�A�D��A���A��K�E�
��5�
!�
!��{�{�1�~�~����Q����4��7�|�#��~�~�c�1�%��,������q�6�*�*�,�D�A������"�A���!�Q�$��K�E��<�=�=�!�$��r�2���'�>��M��v�;�r1c�Z�UR(aURnUS:XagUS:Xagg)zRReturns whether the number is not actually one.

0 if a number
1 if NaN
2 if sNaN
rIr2r�r�r()r�r�)r7r�s  r/�_isnan�Decimal._isnanvs-������)�)�C��c�z������r1c�J�URS:XaUR(aggg)zYReturns whether the number is infinite

0 if finite or not a number
1 if +INF
-1 if -INF
r����r2r()r�rK�r7s r/�_isinfinity�Decimal._isinfinity�s ���9�9����z�z���r1c�L�UR5nUcSnOUR5nU(dU(apUc
[5nUS:XaUR[SU5$US:XaUR[SU5$U(aUR	U5$UR	U5$g)z�Returns whether the number is not actually one.

if self, other are sNaN, signal
if self, other are NaN return nan
return 0

Done before operations.
Fr��sNaNr()r�rr�r
rM)r7�otherr8�self_is_nan�other_is_nans     r/�_check_nans�Decimal._check_nans�s����k�k�m���=� �L� �<�<�>�L��,���$�,���a���+�+�,<�f�(,�.�.��q� ��+�+�,<�f�(-�/�/���}�}�W�-�-��>�>�'�*�*�r1c���Uc
[5nUR(dUR(a�UR5(aUR[SU5$UR5(aUR[SU5$UR5(aUR[SU5$UR5(aUR[SU5$g)aVersion of _check_nans used for the signaling comparisons
compare_signal, __le__, __lt__, __ge__, __gt__.

Signal InvalidOperation if either self or other is a (quiet
or signaling) NaN.  Signaling NaNs take precedence over quiet
NaNs.

Return 0 if neither operand is a NaN.

zcomparison involving sNaNzcomparison involving NaNr()rr��is_snanr�r
�is_qnan�r7r�r8s   r/�_compare_check_nans�Decimal._compare_check_nans�s����?� �l�G����u�0�0��|�|�~�~��+�+�,<�,G�,0�2�2�������+�+�,<�,G�,1�3�3�������+�+�,<�,F�,0�2�2�������+�+�,<�,F�,1�3�3�r1c�F�UR=(d URS:g$)zeReturn True if self is nonzero; otherwise return False.

NaNs and infinities are considered nonzero.
r��r�rLr�s r/�__bool__�Decimal.__bool__�s��
���3�4�9�9��#3�3r1c��UR(dUR(a-UR5nUR5nX#:XagX#:aggU(dU(dgSUR-*$U(dSUR-$URUR:agURUR:agUR5nUR5nXE:Xa|URSUR
UR
-
--nURSUR
UR
-
--nXg:XagXg:aSUR-*$SUR-$XE:�aSUR-$SUR-*$)z�Compare the two non-NaN decimal instances self and other.

Returns -1 if self < other, 0 if self == other and 1
if self > other.  This routine is for internal use only.r(r�r2r�)r�r�rK�adjustedrLr�)r7r��self_inf�	other_inf�
self_adjusted�other_adjusted�self_padded�other_paddeds        r/�_cmp�Decimal._cmp�sQ�����u�0�0��'�'�)�H��)�)�+�I��$���%�������u�{�{�*�+�+������#�#��;�;����#���:�:����#���
�
��
����)���*��)�)�c�4�9�9�u�z�z�+A�&B�B�K� �:�:��U�Z�Z�$�)�)�-C�(D�D�L��*���+��d�j�j�(�(�(��T�Z�Z�'�'�
�
+�����#�#��4�:�:�%�&�&r1c��[XSS9upU[LaU$URX5(agURU5S:H$)NT)�equality_opFr()�_convert_for_comparison�NotImplementedr�r�r�s   r/�__eq__�Decimal.__eq__sE��-�d�t�L����N�"��L����E�+�+���y�y���1�$�$r1c��[X5upU[LaU$URX5nU(agURU5S:$�NFr(�r�r�r�r��r7r�r8rOs    r/�__lt__�Decimal.__lt__"�E��-�d�:����N�"��L��&�&�u�6�����y�y���!�#�#r1c��[X5upU[LaU$URX5nU(agURU5S:*$rrrs    r/�__le__�Decimal.__le__+�E��-�d�:����N�"��L��&�&�u�6�����y�y���1�$�$r1c��[X5upU[LaU$URX5nU(agURU5S:�$rrrs    r/�__gt__�Decimal.__gt__4rr1c��[X5upU[LaU$URX5nU(agURU5S:�$rrrs    r/�__ge__�Decimal.__ge__=rr1c���[USS9nUR(dU(a+UR(aURX5nU(aU$[UR	U55$)z�Compare self to other.  Return a decimal value:

a or b is a NaN ==> Decimal('NaN')
a < b           ==> Decimal('-1')
a == b          ==> Decimal('0')
a > b           ==> Decimal('1')
T��raiseit)�_convert_otherr�r�rr�rs    r/�compare�Decimal.compareFsQ���u�d�3��
����%�*;�*;��"�"�5�2�C���
��t�y�y��'�(�(r1c���UR(ahUR5(a[S5eUR5(a[RU5$UR(a[*$[$URS:�a[SUR[5nO [[UR*[5n[UR5U-[-nUS:�aUOU*nUS:XaS$U$)zx.__hash__() <==> hash(x)z"Cannot hash a signaling NaN value.r(�
r����)r�r�r��is_nanr��__hash__rK�_PyHASH_INFr��pow�_PyHASH_MODULUS�
_PyHASH_10INVr�rL)r7�exp_hash�hash_rOs    r/r�Decimal.__hash__Xs�������|�|�~�~�� D�E�E���������t�,�,��:�:�'�<�'�&�&��9�9��>��2�t�y�y�/�:�H��=�4�9�9�*�o�F�H��D�I�I���)�O�;���q�y�e�u�f���B�Y�r�'�C�'r1c	��[UR[[[UR
55UR5$)zURepresents the number as a triple tuple.

To show the internals exactly as they are.
)rrKr�r�r�rLr�r�s r/�as_tuple�Decimal.as_tuplers+��
�D�J�J��c�#�t�y�y�.A�(B�D�I�I�N�Nr1c� �UR(a+UR5(a[S5e[S5eU(dg[	UR
5nURS:�aUSUR--Sp!O{UR*nUS:�a$US-S:XaUS-nUS-nUS:�aUS-S:XaMUR*n[X*-R5S-
U5nU(aX-nXE-nSU-U-nUR(aU*nX4$)aGExpress a finite Decimal instance in the form n / d.

Returns a pair (n, d) of integers.  When called on an infinity
or NaN, raises OverflowError or ValueError respectively.

>>> Decimal('3.14').as_integer_ratio()
(157, 50)
>>> Decimal('-123e5').as_integer_ratio()
(-12300000, 1)
>>> Decimal('0.00').as_integer_ratio()
(0, 1)

z#cannot convert NaN to integer ratioz(cannot convert Infinity to integer ratior�r(rr2r�)
r�rr��
OverflowErrorr�rLr��minr�rK)r7rIr��d5�d2�shift2s      r/r��Decimal.as_integer_ratioys������{�{�}�}� �!F�G�G�#�$N�O�O���
��	�	�N���9�9��>��r�4�9�9�}�$�a�q��)�)��B��q�&�Q��U�a�Z��a����a����q�&�Q��U�a�Z��)�)��B��!�b�&�,�,�.��2�B�7�F���������2����A��:�:���A��t�r1c��S[U5-$)z0Represents the number as an instance of Decimal.z
Decimal('%s'))r�r�s r/�__repr__�Decimal.__repr__�s����T��*�*r1c�(�SS/URnUR(aIURS:XaUS-$URS:XaUS-UR-$US-UR-$UR[	UR5-nURS::a	US	:�aUnO1U(dS
nO'URS:XaUS
-S-S
-
nOUS
-
S-S
-nUS::aSnS
SU*--UR-nOeU[	UR5:�a+URSU[	UR5-
--nSnO!URSUnS
URUS-nXE:XaSnO&Uc
[5nSS/URSXE-
--nX6-U-U-$)z�Return string representation of the number in scientific notation.

Captures all of the information in the underlying representation.
r�r�r��InfinityrI�NaNr�r(���r2r�r��.N�e�Ez%+d)rKr�r�rLr�rr~)	r7�engr8r\�
leftdigits�dotplacer�r�r�s	         r/�__str__�Decimal.__str__�s����C�y����$������y�y�C���j�(�(����c�!��e�|�d�i�i�/�/��f�}�t�y�y�0�0��Y�Y��T�Y�Y��/�
�
�9�9��>�j�2�o�!�H���H�
�Y�Y�#�
�"�Q��!�+�a�/�H�#�Q��!�+�a�/�H��q�=��G��S�8�)�_�,�t�y�y�8�H�
��T�Y�Y��
'��i�i��X�c�$�)�)�n�%<� =�=�G��H��i�i�	��*�G��T�Y�Y�x�y�1�1�H��!��C���$�,����*�W�-�-�.��*�:M�1N�N�C��~��(�3�.�.r1c�"�URSUS9$)aConvert to a string, using engineering notation if an exponent is needed.

Engineering notation has an exponent which is a multiple of 3.  This
can leave up to 3 digits to the left of the decimal place and may
require the addition of either one or two trailing zeros.
T)r8r8)r;�r7r8s  r/�
to_eng_string�Decimal.to_eng_string�s���|�|��g�|�6�6r1c��UR(aURUS9nU(aU$Uc
[5nU(d%UR[:waUR5nOUR
5nURU5$)zBReturns a copy with the sign switched.

Rounds, if it has reason.
r�)r�r�rrur�copy_abs�copy_negate�_fix�r7r8rOs   r/�__neg__�Decimal.__neg__�sn��
����"�"�7�"�3�C���
��?� �l�G���(�(�K�7��-�-�/�C��"�"�$�C��x�x�� � r1c��UR(aURUS9nU(aU$Uc
[5nU(d%UR[:waUR5nO[
U5nURU5$)zXReturns a copy, unless it is a sNaN.

Rounds the number (if more than precision digits)
r�)r�r�rrurrBrrDrEs   r/�__pos__�Decimal.__pos__sg��
����"�"�7�"�3�C���
��?� �l�G���(�(�K�7��-�-�/�C��$�-�C��x�x�� � r1c���U(dUR5$UR(aURUS9nU(aU$UR(aUR	US9nU$URUS9nU$)z�Returns the absolute value of self.

If the keyword argument 'round' is false, do not round.  The
expression self.__abs__(round=False) is equivalent to
self.copy_abs().
r�)rBr�r�rKrFrI)r7�roundr8rOs    r/�__abs__�Decimal.__abs__sl����=�=�?�"�����"�"�7�"�3�C���
��:�:��,�,�w�,�/�C��
��,�,�w�,�/�C��
r1c��[U5nU[LaU$Uc
[5nUR(dUR(a�UR	X5nU(aU$UR5(aPURUR:wa+UR5(aUR[S5$[U5$UR5(a[U5$[URUR5nSnUR[:XaURUR:waSnU(dPU(dI[URUR5nU(aSn[USU5nURU5nU$U(dS[!XARUR"-
S-
5nUR%XBR5nURU5nU$U(dS[!X@RUR"-
S-
5nUR%XBR5nURU5nU$['U5n['U5n[)XxUR"5upx['5n	UR*UR*:wa�UR,UR,:Xa [USU5nURU5nU$UR,UR,:aX�p�UR*S:Xa+SU	lUR*UR*sUlUlO6SU	lO.UR*S:XaSU	lSuUlUlOSU	lUR*S:XaUR,UR,-U	lOUR,UR,-
U	lUR.U	l[U	5nURU5nU$)zRReturns self + other.

-INF + INF (or the reverse) cause InvalidOperation errors.
z
-INF + INFr(r2r�)r(r()rr�rr�r�r�rKr�r
rr)r�rurrJrD�maxrv�_rescaler��
_normalizer\r�r�)
r7r�r8rOr��negativezeror\�op1�op2r�s
          r/�__add__�Decimal.__add__.s���
�u�%���N�"��L��?� �l�G����u�0�0��"�"�5�2�C���
����!�!��:�:����,��1B�1B�1D�1D�"�/�/�0@�,�O�O��t�}�$�� � �"�"��u�~�%��$�)�)�U�Z�Z�(�������{�*�t�z�z�U�[�[�/H��L��E��t�z�z�5�;�;�/�D����"�4��c�2�C��(�(�7�#�C��J���c�:�:����4�Q�6�7�C��.�.��&6�&6�7�C��(�(�7�#�C��J���c�9�9�w�|�|�3�A�5�6�C��-�-��%5�%5�6�C��(�(�7�#�C��J��t�n���u�o���c����5�������8�8�s�x�x���w�w�#�'�'�!�&�|�S�#�>���h�h�w�'���
��w�w���� ��S��x�x�1�}����%(�X�X�s�x�x�"���#�(����
�X�X��]��F�K�!'��C�H�c�h��F�K��8�8�q�=����3�7�7�*�F�J����3�7�7�*�F�J��W�W��
��f�o���h�h�w����
r1c���[U5nU[LaU$UR(dUR(aURXS9nU(aU$UR	UR5US9$)zReturn self - otherr�)rr�r�r�rVrCrs    r/�__sub__�Decimal.__sub__�sc���u�%���N�"��L����u�0�0��"�"�5�"�:�C���
��|�|�E�-�-�/��|�A�Ar1c�L�[U5nU[LaU$URXS9$)zReturn other - selfr�)rr�rYr�s   r/�__rsub__�Decimal.__rsub__�s*���u�%���N�"��L��}�}�T�}�3�3r1c��[U5nU[LaU$Uc
[5nURUR-nUR(dUR(a�URX5nU(aU$UR
5(a&U(dUR[S5$[U$UR
5(a&U(dUR[S5$[U$URUR-nU(aU(d [USU5nURU5nU$URS:Xa)[X1RU5nURU5nU$URS:Xa)[X0RU5nURU5nU$[U5n[U5n[U[UR UR -5U5nURU5nU$)zLReturn self * other.

(+-) INF * 0 (or its reverse) raise InvalidOperation.
z(+-)INF * 0z0 * (+-)INFr��1)rr�rrKr�r�r�r�r
rZr�rJrDrLr�r�r�)r7r�r8�
resultsignrO�	resultexprTrUs        r/�__mul__�Decimal.__mul__�s���
�u�%���N�"��L��?� �l�G��Z�Z�%�+�+�-�
����u�0�0��"�"�5�2�C���
����!�!��"�/�/�0@�-�P�P�&�z�2�2�� � �"�"��"�/�/�0@�-�P�P�&�z�2�2��I�I��
�
�*�	��5�"�:�s�I�>�C��(�(�7�#�C��J��9�9���"�:�z�z�9�E�C��(�(�7�#�C��J��:�:���"�:�y�y�)�D�C��(�(�7�#�C��J��t�n���u�o���z�3�s�w�w����/@�+A�9�M���h�h�w����
r1c��[U5nU[La[$Uc
[5nURUR-nUR(dUR(a�URX5nU(aU$UR
5(a+UR
5(aUR[S5$UR
5(a	[U$UR
5(a1UR[S5 [USUR55$U(d4U(dUR[S5$UR[SU5$U(dURUR-
nSnGO[!UR"5[!UR"5-
UR$-S-nURUR-
U-
n['U5n['U5n	US:�a)[)UR*SU--U	R*5upjO)[)UR*U	R*SU*--5upjU
(aUS	-S:XaUS-
nOAURUR-
nX[:a#US-S:XaUS-nUS-
nX[:aUS-S:XaM[U[-U5U5nUR/U5$)
zReturn self / other.z(+-)INF/(+-)INFzDivision by infinityr�z0 / 0zx / 0r(r2rr�)rr�rrKr�r�r�r�r
rZr	rJ�Etinyrrr�r�rLrvr��divmodr�r�rD)r7r�r8r\rOr�r��shiftrTrU�	remainder�	ideal_exps            r/�__truediv__�Decimal.__truediv__�sL���u�%���N�"�!�!��?� �l�G��z�z�E�K�K�'�����u�0�0��"�"�5�2�C���
����!�!�e�&7�&7�&9�&9��+�+�,<�>O�P�P����!�!�&�t�,�,�� � �"�"��$�$�W�.D�E�'��c�7�=�=�?�C�C����+�+�,=�w�G�G��'�'����F�F���)�)�e�j�j�(�C��E���
�
�O�c�$�)�)�n�4�w�|�|�C�a�G�E��)�)�e�j�j�(�5�0�C��4�.�C��5�/�C���z�#)�#�'�'�B��I�*=�s�w�w�#G� ��y�#)�#�'�'�3�7�7�R�%��Z�3G�#H� ����1�9��>��Q�J�E��!�I�I��
�
�2�	��o�%�"�*��/��b�L�E��1�H�C��o�%�"�*��/��t�S��Z��5���x�x�� � r1c���URUR-nUR5(a
URnO [URUR5nUR	5UR	5-
nU(aUR5(dUS::a([USS5UR
XBR54$XRR::a�[U5n[U5nURUR:�a0U=RSURUR-
--slO/U=RSURUR-
--sl[URUR5up�USUR-:a6[U[U5S5[UR[U	5U54$UR[S5n
X�4$)z�Return (self // other, self % other), to context.prec precision.

Assumes that neither self nor other is a NaN, that self is not
infinite and that other is nonzero.
rr�r(rz%quotient too large in //, % or divmod)rKr�r�r)r�rJrQrurvr�r�r�rfr�r�r)r7r�r8r\ri�expdiffrTrU�q�rrOs           r/�_divide�Decimal._divides}���z�z�E�K�K�'��������	�	�I��D�I�I�u�z�z�2�I��-�-�/�E�N�N�$4�4���u�(�(�*�*�g��m�$�T�3��2��M�M�)�-=�-=�>�@�
@��l�l�"��4�.�C��5�/�C��w�w�#�'�'�!����2����#�'�'� 1�2�2�����2����#�'�'� 1�2�2���#�'�'�3�7�7�+�D�A��2�w�|�|�#�#�(��s�1�v�q�9�(����S��V�Y�G�I�I��"�"�#5�#J�L���x�r1c�L�[U5nU[LaU$URXS9$)z)Swaps self/other and returns __truediv__.r�)rr�rjr�s   r/�__rtruediv__�Decimal.__rtruediv__1s-���u�%���N�"��L�� � �� �7�7r1c�j�[U5nU[LaU$Uc
[5nURX5nU(aX34$URUR-nUR5(aMUR5(aUR
[S5nX34$[UUR
[S54$U(dMU(dUR
[S5nX34$UR
[SU5UR
[S54$URX5upVURU5nXV4$)z&
Return (self // other, self % other)
zdivmod(INF, INF)�INF % xzdivmod(0, 0)�x // 0�x % 0)
rr�rr�rKr�r�r
rZrrrprD)r7r�r8rOr\�quotientrhs       r/�
__divmod__�Decimal.__divmod__8s-���u�%���N�"��L��?� �l�G����u�.����:���z�z�E�K�K�'�������� � �"�"��*�*�+;�=O�P���x��'��-��,�,�-=�y�I�K�K����*�*�+<�n�M���x���,�,�^�X�t�L��,�,�-=�w�G�I�I�#�l�l�5�:����N�N�7�+�	��"�"r1c�L�[U5nU[LaU$URXS9$)z(Swaps self/other and returns __divmod__.r�)rr�rzr�s   r/�__rdivmod__�Decimal.__rdivmod__\s-���u�%���N�"��L������6�6r1c��[U5nU[LaU$Uc
[5nURX5nU(aU$UR	5(aUR[S5$U(d3U(aUR[S5$UR[S5$URX5SnURU5nU$)z
self % other
rvrxz0 % 0r2)
rr�rr�r�r�r
rrprD)r7r�r8rOrhs     r/�__mod__�Decimal.__mod__cs����u�%���N�"��L��?� �l�G����u�.����J�������'�'�(8�)�D�D����+�+�,<�g�F�F��+�+�,=�w�G�G��L�L��0��3�	��N�N�7�+�	��r1c�L�[U5nU[LaU$URXS9$)z%Swaps self/other and returns __mod__.r�)rr�r�r�s   r/�__rmod__�Decimal.__rmod__~�*���u�%���N�"��L��}�}�T�}�3�3r1c��Uc
[5n[USS9nURX5nU(aU$UR5(aUR	[
S5$U(d3U(aUR	[
S5$UR	[S5$UR5(a[U5nURU5$[URUR5nU(d([URSU5nURU5$UR5UR5-
nXRRS-:�aUR	[5$US::a,UR!XBR"5nURU5$[%U5n[%U5nUR&UR&:�a0U=R(S	UR&UR&-
--slO/U=R(S	UR&UR&-
--sl[+UR(UR(5up�S
U	-US--UR(:�aX�R(-n	US-
nUS	UR-:�aUR	[5$URn
U	S:aSU
-
n
U	*n	[U
[-U	5U5nURU5$)z9
Remainder nearest to 0-  abs(remainder-near) <= other/2
Trzremainder_near(infinity, x)zremainder_near(x, 0)zremainder_near(0, 0)r�r2rrr�r()rrr�r�r�r
rrrDr)r�rJrKr�rvrrQrur�r�r�rfr�)r7r�r8rO�ideal_exponentrmrTrUrnror\s           r/�remainder_near�Decimal.remainder_near�su���?� �l�G��u�d�3�����u�.����J�������'�'�(8�(E�G�
G����+�+�,<�,B�D�D��+�+�,=�,B�D�D�������$�-�C��8�8�G�$�$��T�Y�Y��
�
�3���"�4�:�:�s�N�C�C��8�8�G�$�$��-�-�/�E�N�N�$4�4���l�l�Q�&�&��'�'�(:�;�;��b�=��-�-��0@�0@�A�C��8�8�G�$�$��t�n���u�o���7�7�c�g�g���G�G�r�C�G�G�c�g�g�-�.�.�G��G�G�r�C�G�G�c�g�g�-�.�.�G��c�g�g�s�w�w�'���
�Q�3�!�A�#�;���� �
���L�A�
��F�A���G�L�L� � ��'�'�(:�;�;��z�z���q�5��T�6�D���A��t�S��V�^�<���x�x�� � r1c��[U5nU[LaU$Uc
[5nURX5nU(aU$UR	5(aKUR	5(aUR[S5$[URUR-$U(dKU(a.UR[SURUR-5$UR[S5$URX5S$)z
self // otherz
INF // INFrwz0 // 0r()rr�rr�r�r�r
rZrKrrrprs    r/�__floordiv__�Decimal.__floordiv__�s����u�%���N�"��L��?� �l�G����u�.����J������� � �"�"��+�+�,<�l�K�K�&�t�z�z�E�K�K�'?�@�@����+�+�N�H�,0�J�J����,D�F�F��+�+�,=�x�H�H��|�|�E�+�A�.�.r1c�L�[U5nU[LaU$URXS9$)z*Swaps self/other and returns __floordiv__.r�)rr�r�r�s   r/�
__rfloordiv__�Decimal.__rfloordiv__�s-���u�%���N�"��L��!�!�$�!�8�8r1c���UR5(a6UR5(a[S5eUR(aSOSnO[	U5n[U5$)zFloat representation.z%Cannot convert signaling NaN to floatz-nan�nan)r�r�r�rKr�r��r7�ss  r/�	__float__�Decimal.__float__�sC���;�;�=�=��|�|�~�~� �!H�I�I��*�*��%�A��D�	�A��Q�x�r1c��UR(a@UR5(a[S5eUR5(a[	S5eSUR
-nURS:�a(U[UR5-SUR--$U[URSUR=(d S5-$)z1Converts self to an int, truncating if necessary.zCannot convert NaN to integerz"Cannot convert infinity to integerr�r(rNr�)	r�r�r�r�r(rKr�r�rLr�s  r/�__int__�Decimal.__int__�s�������{�{�}�}� �!@�A�A��!�!�#�#�#�$H�I�I�
�$�*�*����9�9��>��S����^�#�B��	�	�M�1�1��S����:�D�I�I�.�5�#�6�6�6r1c��U$r,r-r�s r/�real�Decimal.reals���r1c��[S5$)Nr(�rr�s r/�imag�Decimal.imags���q�z�r1c��U$r,r-r�s r/�	conjugate�Decimal.conjugates���r1c�*�[[U55$r,)�complexr�r�s r/�__complex__�Decimal.__complex__s���u�T�{�#�#r1c��URnURUR-
n[U5U:�aAU[U5U-
SR	S5n[URX RS5$[U5$)z2Decapitate the payload of a NaN to fit the contextNr�T)	rLrvrr�r�rJrKr�r)r7r8�payload�max_payload_lens    r/rM�Decimal._fix_nansm���)�)��"�,�,����6���w�<�/�)��c�'�l�?�:�;�<�C�C�C�H�G�#�D�J�J����D�I�I��t�}�r1c�L�UR(a1UR5(aURU5$[U5$UR	5nUR5nU(d�URU/URn[[URU5U5nXPR:wa,UR[5 [URSU5$[U5$[UR 5UR-UR"-
nXc:�aMUR[$SUR5nUR[&5 UR[(5 U$Xb:nU(aUnURU:Ga�[UR 5UR-U-
n	U	S:a[URSUS-
5nSn	UR*UR,n
U
"X	5nUR SU	=(d SnUS:�a:[/[1U5S-5n[U5UR":�a
USSnUS-
nXc:�a"UR[$SUR5nO[URX�5nU(aU(aUR[25 U(aUR[45 U(aUR[&5 UR[(5 U(dUR[5 U$U(aUR[45 URS:XaZURU:�aJUR[5 UR SURU-
--n
[URX�5$[U5$)z�Round if it is necessary to keep self within prec precision.

Rounds and fixes the exponent.  Does not raise on a sNaN.

Arguments:
self - Decimal instance
context - context used.
r��
above Emaxr(r_r2Nr�)r�r�rMrre�Etoprwrr)rPr�r�r	rJrKr�rLrvrrr
�_pick_rounding_functionrur�r�rr)r7r8rer��exp_max�new_exp�exp_minrO�self_is_subnormalr��rounding_method�changedr�r�s              r/rD�Decimal._fix&s�������{�{�}�}��}�}�W�-�-��t�}�$��
�
����|�|�~����|�|�T�*�7�=�=�9�G��#�d�i�i��/��9�G��)�)�#��$�$�W�-�'��
�
�C��A�A��t�}�$��d�i�i�.�4�9�9�,�w�|�|�;���>��&�&�x��t�z�z�J�C�� � ��)�� � ��)��J�#�O����G��9�9�w������^�d�i�i�/�'�9�F���z�'��
�
�C����C����"�:�:�7�;K�;K�L�O�%�d�3�G��I�I�g�v�&�-�#�E���{��C��J�q�L�)���u�:����,�!�#�2�J�E��q�L�G��~��*�*�8�\�4�:�:�N��&�t�z�z�5�B���,��$�$�Y�/� ��$�$�Y�/���$�$�W�-�� � ��)���$�$�W�-��J��� � ��+��=�=�A��$�)�)�d�"2�� � ��)��)�)�c�4�9�9�t�+;�&<�<�K�#�D�J�J��B�B��t�}�r1c�<�[URU5(agg)z(Also known as round-towards-0, truncate.r(r�)�
_all_zerosrL�r7rvs  r/�_round_down�Decimal._round_down�s���d�i�i��&�&��r1c�&�URU5*$)zRounds away from 0.)r�r�s  r/�	_round_up�Decimal._round_up�s��� � ��&�&�&r1c�d�URUS;ag[URU5(agg)zRounds 5 up (away from 0)�56789r2r(r�)rLr�r�s  r/�_round_half_up�Decimal._round_half_up�s,���9�9�T�?�g�%��
��	�	�4�
(�
(��r1c�\�[URU5(agURU5$)zRound 5 downr���_exact_halfrLr�r�s  r/�_round_half_down�Decimal._round_half_down�s'���t�y�y�$�'�'���&�&�t�,�,r1c��[URU5(aUS:XdURUS-
S;agURU5$)z!Round 5 to even, rest to nearest.r(r2�02468r�r�r�s  r/�_round_half_even�Decimal._round_half_even�sB���t�y�y�$�'�'����d�i�i��Q��/�7�:���&�&�t�,�,r1c�j�UR(aURU5$URU5*$)z(Rounds up (not away from 0 if negative.)�rKr�r�s  r/�_round_ceiling�Decimal._round_ceiling�s.���:�:��#�#�D�)�)��$�$�T�*�*�*r1c�j�UR(dURU5$URU5*$)z'Rounds down (not towards 0 if negative)r�r�s  r/�_round_floor�Decimal._round_floor�s.���z�z��#�#�D�)�)��$�$�T�*�*�*r1c��U(a'URUS-
S;aURU5$URU5*$)z)Round down unless digit prec-1 is 0 or 5.r2�05)rLr�r�s  r/�_round_05up�Decimal._round_05up�s>���D�I�I�d�1�f�%�T�1��#�#�D�)�)��$�$�T�*�*�*r1)rrrrrrrrc�<�Ub?[U[5(d[S5e[SSU*5nUR	U5$UR
(a+UR
5(a[S5e[S5e[URS[55$)a�Round self to the nearest integer, or to a given precision.

If only one argument is supplied, round a finite Decimal
instance self to the nearest integer.  If self is infinite or
a NaN then a Python exception is raised.  If self is finite
and lies exactly halfway between two integers then it is
rounded to the integer with even last digit.

>>> round(Decimal('123.456'))
123
>>> round(Decimal('-456.789'))
-457
>>> round(Decimal('-3.0'))
-3
>>> round(Decimal('2.5'))
2
>>> round(Decimal('3.5'))
4
>>> round(Decimal('Inf'))
Traceback (most recent call last):
  ...
OverflowError: cannot round an infinity
>>> round(Decimal('NaN'))
Traceback (most recent call last):
  ...
ValueError: cannot round a NaN

If a second argument n is supplied, self is rounded to n
decimal places using the rounding mode for the current
context.

For an integer n, round(self, -n) is exactly equivalent to
self.quantize(Decimal('1En')).

>>> round(Decimal('123.456'), 0)
Decimal('123')
>>> round(Decimal('123.456'), 2)
Decimal('123.46')
>>> round(Decimal('123.456'), -2)
Decimal('1E+2')
>>> round(Decimal('-Infinity'), 37)
Decimal('NaN')
>>> round(Decimal('sNaN123'), 0)
Decimal('NaN123')

z+Second argument to round should be integralr(r_�cannot round a NaN�cannot round an infinity)r�r�r�rJ�quantizer�rr�r(rQr)r7rIr�s   r/�	__round__�Decimal.__round__�s���^
�=��a��%�%�� M�N�N�"�1�c�A�2�.�C��=�=��%�%�����{�{�}�}� �!5�6�6�#�$>�?�?��4�=�=��O�4�5�5r1c��UR(a+UR5(a[S5e[S5e[	URS[55$)z�Return the floor of self, as an integer.

For a finite Decimal instance self, return the greatest
integer n such that n <= self.  If self is infinite or a NaN
then a Python exception is raised.

r�r�r()r�rr�r(r�rQrr�s r/�	__floor__�Decimal.__floor__
sF������{�{�}�}� �!5�6�6�#�$>�?�?��4�=�=��K�0�1�1r1c��UR(a+UR5(a[S5e[S5e[	URS[55$)z�Return the ceiling of self, as an integer.

For a finite Decimal instance self, return the least integer n
such that n >= self.  If self is infinite or a NaN then a
Python exception is raised.

r�r�r()r�rr�r(r�rQrr�s r/�__ceil__�Decimal.__ceil__sF������{�{�}�}� �!5�6�6�#�$>�?�?��4�=�=��M�2�3�3r1c	��[USS9n[USS9nUR(dUR(GaUc
[5nURS:XaUR	[
SU5$URS:XaUR	[
SU5$URS:XaUnGOURS:XaUnGO	URS:Xa>U(dUR	[
S5$[URUR-nO�URS:Xa=U(dUR	[
S5$[URUR-nOm[URUR-[[UR5[UR5-5URUR-5nWRX#5$)	a
Fused multiply-add.

Returns self*other+third with no rounding of the intermediate
product self*other.

self and other are multiplied together, with no rounding of
the result.  The third operand is then added to the result,
and a single final rounding is performed.
Trr�r�rIr�zINF * 0 in fmaz0 * INF in fma)
rr�rr�r�r
rZrKrJr�r�rLrV)r7r��thirdr8�products     r/�fma�Decimal.fma+s~���u�d�3���u�d�3�����u�0�0�0���$�,���y�y�C���+�+�,<�f�d�K�K��z�z�S� ��+�+�,<�f�e�L�L��y�y�C�������s�"������c�!��"�/�/�0@�0@�B�B�)�$�*�*�u�{�{�*B�C�����s�"��"�/�/�0@�0@�B�B�)�$�*�*�u�{�{�*B�C���&�t�z�z�E�K�K�'?�'*�3�t�y�y�>�C��
�
�O�+K�'L�'+�y�y�5�:�:�'=�?�G����u�.�.r1c���[U5nU[LaU$[U5nU[LaU$Uc
[5nUR5nUR5nUR5nU(dU(dU(a�US:XaUR	[
SU5$US:XaUR	[
SU5$US:XaUR	[
SU5$U(aUR
U5$U(aUR
U5$UR
U5$UR5(a*UR5(aUR5(dUR	[
S5$US:aUR	[
S5$U(dUR	[
S5$UR5UR:�aUR	[
S5$U(dU(dUR	[
S5$UR5(aSnOURn[[U55n[UR55n[UR55n	URU-[!S	UR"U5-U-n[%U	R"5Hn
[!US	U5nM [!X�RU5n['U[)U5S5$)
z!Three argument version of __pow__r�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)rr�rr�r�r
rM�
_isintegerr�rv�_isevenrKr�r�r��to_integral_valuerr��rangerJr�)r7r��modulor8r�r��
modulo_is_nanr\�base�exponent�is           r/�
_power_modulo�Decimal._power_moduloWs����u�%���N�"��L���'���^�#��M��?� �l�G��k�k�m���|�|�~���
�
��
��,�-��a���+�+�,<�f�(,�.�.��q� ��+�+�,<�f�(-�/�/���!��+�+�,<�f�(.�0�0���}�}�W�-�-���~�~�g�.�.��?�?�7�+�+����!�!�� � �"�"��!�!�#�#��'�'�(8�)L�M�
M��1�9��'�'�(8�)O�P�
P���'�'�(8�(H�J�
J�
�?�?�����,��'�'�(8�);�<�
<��T��'�'�(8�)>�?�
?��=�=�?�?��D��:�:�D��S��[�!����.�.�0�1���E�3�3�5�6�����6�!�C��D�H�H�f�$=�=��G���x�|�|�$�A��t�R��(�D�%��4���v�.����c�$�i��3�3r1c�	�[U5nURURpTUS-S:XaUS-nUS-
nUS-S:XaM[U5nURURp�US-S:XaUS-nUS-
nUS-S:XaMUS:Xa�XW-nUS-S:XaUS-nUS-
nUS-S:XaMUS:agUSU--n	URS:XaU	*n	UR	5(a:UR
S:Xa*UR[U5-n
[X�-
US-
5nOSn[SSSU--X�-
5$URS:XGa]US-nUS;ahXD*-U:wag[U5S-
n
US-S	-nU[[U55:�ag[X�-U5n
[XW-U5nU
bUcgX�:�agS
U
-nO�US
:Xa�[U5S-S	-n
[S
U
-U5upOU(agUS
-S:XaUS
-nU
S-n
US
-S:XaMUS-S-nU[[U55:�ag[X�-U5n
[XW-U5nU
bUcgX�:�agS
U
-nOgUS:�dU5eUS-S:wdU5e[U5n[U5U:�agU
*U-
n[SUU5$US:�aUSU--SnnO�US:wa%[[[Xu-555U*::ag[U5n[[[U5U-55U*::agUSU*-nnUS
-US
-s=:XaS:Xa$O O!US
-nUS
-nUS
-US
-s=:XaS:XaMO US
-US
-s=:XaS:Xa$O O!US
-nUS
-nUS
-US
-s=:XaS:XaMO US:�alWU::ag[UU5unnUS:wagS[U5*U-*-n[UUUS-
-5unnUU::aOUUS-
-U-U-nM,UU:XaUS:XdgUnUS:�aUUS-[U5-:�agUU-nUU-nUS:�dU5eUS-S:wdU5e[U5n[U5U:�agUR	5(aCUR
S:Xa3UR[U5-n
[XZ-
U[U5-
5nOSn[SUSU--X[-
5$)a Attempt to compute self**other exactly.

Given Decimals self and other and an integer p, attempt to
compute an exact result for the power self**other, with p
digits of precision.  Return None if self**other is not
exactly representable in p digits.

Assumes that elimination of special cases has already been
performed: self and other must both be nonspecial; self must
be positive and not numerically equal to 1; other must be
nonzero.  For efficiency, other._exp should not be too large,
so that 10**abs(other._exp) is a feasible calculation.rr(r2Nr_r�)r�����]�Ar��r�r��d)r�r�r�r\r�rKr�r)rJ�_nbitsr�r��_decimal_lshift_exactrfr��	_log10_lb)r7r��p�x�xc�xe�y�yc�yer�r��zeros�
last_digitr6�emaxrh�strxcr�rI�xc_bits�rem�arnro�str_xcs                         r/�_power_exact�Decimal._power_exact�s[��t
�T�N��������B��2�g��l��2�I�B��!�G�B��2�g��l�
�U�O��������B��2�g��l��2�I�B��!�G�B��2�g��l���7��H�B��r�'�Q�,��r�	���a����r�'�Q�,��A�v���B��F�{�H��v�v��{�$�9�����!�!�e�k�k�Q�&6�!%���3�u�:�!5���H�3�Q�q�S�9����#�A�s�S��Y����G�G�
�6�6�Q�;��b��J��Y�&���8�r�>���2�J�q�L��6��t�R�x����S��Y��'��*�!�&�"�5��*�2�7�B�7���9��
���8����T���q���2�J�r�M�2�%�� &�q�!�t�R� 0�
�����1�f��k��1�H�B���F�A��1�f��k���t�Q�w����S��Y��'��)�!�&�"�5��*�2�7�B�7���9��
���8����T���
��6��4��6���7�a�<�%��%�<���G�E��5�z�A�~����B��B�#�A�u�b�1�1���7��b�"�f�9�a�q�A�q��Q�w�3�s�3�r�u�:��/�B�3�6���R�j�G��3�s�2�w�w��'�(�R�C�/���r�R�C�y�q�A��a�%�1�q�5�%�A�%��a����a����a�%�1�q�5�%�A�%��a�%�1�q�5�%�A�%��a����a����a�%�1�q�5�%�A�%�

�q�5��!�|���R��m�G�B���a�x����r�
�{�A�~�&�&�A���b�!�a��c�(�+���1���6���A�a�C��1��q�(�A����F�q�A�v���B���6�a�!�C�%��2��.�.��
��U��
�a����A�v��t��v��B�w�!�|�!�T�!�|��R����v�;��?��
�����%�+�+��"2�!�Y�Y�s�5�z�1�N���)�1�S��[�=�9�E��E���6�#�e�)�#3�R�X�>�>r1c�"�UbURXU5$[U5nU[LaU$Uc
[5nUR	X5nU(aU$U(d#U(dUR[S5$[$SnURS:XaZUR5(aUR5(dSnOU(aUR[S5$UR5nU(d&URS:Xa
[USS5$[U$UR5(a&URS:Xa	[U$[USS5$U[:Xa�UR5(a�URS:XaSnO'XR:�a
URnO[!U5nUR"U-nUSUR-
:a$SUR-
nUR[$5 O9UR[&5 UR[$5 SUR-
n[USSU*--U5$UR)5nUR5(a,URS:HUS::Xa
[USS5$[U$SnSn	UR+5UR)5-n
US:�URS:H:Xa=U
[-[/UR055:�a[USUR0S-5nO9UR35nU
[-[/U*55:�a[USUS-
5nUcJUR5XRS-5nUb)US:Xa![SUR6UR"5nS	n	Uc�URn[9U5n
U
R U
R:p�[9U5nUR UR:nnUR<S:XaU*nS
n[?X�UUUU-5unnUSS[-[/U55U-
S-
---(aOUS
-
nMD[U[/U5U5nU	(Ga�UR5(Gd�[-UR65UR::aYURS-[-UR65-
n[URUR6SU--UR"U-
5nURA5nURC5 [DHnSURFU'M URIU5nUR[&5 URJ[L(aUR[N5 URJ[P(a!UR[PS
UR5 [N[L[&[$[R4H*nURJU(dMURU5 M, U$URIU5nU$)a�Return self ** other [ % modulo].

With two arguments, compute self**other.

With three arguments, compute (self**other) % modulo.  For the
three argument form, the following restrictions on the
arguments hold:

 - all three arguments must be integral
 - other must be nonnegative
 - either self or other (or both) must be nonzero
 - modulo must be nonzero and must have at most p digits,
   where p is the context precision.

If any of these restrictions is violated the InvalidOperation
flag is raised.

The result of pow(self, other, modulo) is identical to the
result that would be obtained by computing (self**other) %
modulo with unbounded precision, but is computed more
efficiently.  It is always exact.
Nz0 ** 0r(r2z+x ** y with x negative and y not an integerr�r_FTr�r�rr�)*r�rr�rr�r�r
�_OnerKr�r�rCrJrZr�rvr�r�r
rr��_log10_exp_boundr�r�rwrer
rLr�r�r\�_dpowerr�r��_signalsr�rDr�rrrr	)r7r�r�r8rO�result_sign�
multiplierr��self_adj�exact�boundrer�r�rrrrr�extrar�rm�
newcontext�	exceptions                        r/�__pow__�Decimal.__pow__�sI��0���%�%�e�W�=�=��u�%���N�"��L��?� �l�G����u�.����J����+�+�,<�h�G�G������:�:��?����!�!��}�}���"#�K���"�/�/�0@�E�G�G��#�#�%�D���{�{�a��'��S�!�<�<�&�{�3�3�������{�{�a��&�{�3�3�'��S�!�<�<�
�4�<����!�!�
�;�;�!�#�!"�J��\�\�)�!(���J�!$�U��J��i�i�*�,����7�<�<��'��G�L�L�.�C��(�(��1���$�$�W�-��$�$�W�-�����n��#�K��S�#��X��s�C�C��=�=�?����������q� �h��l�3�'��S�!�<�<�&�{�3�3������%�%�'�%�.�.�*:�:����M�u�{�{�a�/�0���C����-�.�.�&�{�C����a��H����M�M�O�E���C���K�(�(�&�{�C��q��A���;��#�#�E�<�<�!�+;�<�C����!�#�*�1�c�h�h����A�C����;����A����A��U�U�A�E�E�����A��U�U�A�E�E��B��v�v��{��S���E��$�R�R��Q�u�W�=�
��s��A�b�3�s�5�z�?�1�#4�Q�#6�7�7�8����
��	�#�;��E�
�C�@�C���)�)�+�+��3�8�8�}����,�!�,�,��*�S����]�:��&�s�y�y�#�(�(�3�w�;�2F�'*�x�x��'7�9��!����J��"�"�$�%�	�./�
� � ��+�&��(�(�:�&�C�
�#�#�G�,����	�*��'�'�	�2�����)��$�$�X�|�S�Y�Y�G�&�	�7�G�W�L�	��#�#�I�.�.��(�(��3�M��
��(�(�7�#�C��
r1c�L�[U5nU[LaU$URXS9$)z%Swaps self/other and returns __pow__.r�)rr�rr�s   r/�__rpow__�Decimal.__rpow__|	r�r1c�Z�Uc
[5nUR(aURUS9nU(aU$URU5nUR	5(aU$U(d[URSS5$URUR5/URn[UR5nURnURUS-
S:Xa,Xd:a'US-
nUS-nURUS-
S:XaXd:aM'[URURSUU5$)z?Normalize- strip trailing 0s, change anything equal to 0 to 0e0Nr�r�r(r2)
rr�r�rDr�rJrKrwr�rr�rLr�)r7r8rO�dupr��endr�s       r/�	normalize�Decimal.normalize�	s���?� �l�G�����"�"�7�"�3�C���
��i�i�� ���?�?����J��#�C�I�I�s�A�6�6��<�<�����0����?���#�(�(�m���h�h���h�h�s�1�u�o��$����1�H�C��1�H�C��h�h�s�1�u�o��$��� ��	�	�3�8�8�D�S�>�3�?�?r1c���[USS9nUc
[5nUcURnUR(dUR(a�UR	X5nU(aU$UR5(dUR5(aKUR5(a UR5(a[
U5$UR[S5$UR5URs=::aUR::dO UR[S5$U(d2[URSUR5nURU5$UR5nXSR:�aUR[S5$XQR-
S-UR :�aUR[S5$UR#URU5nUR5UR:�aUR[S5$[%UR&5UR :�aUR[S5$U(a3UR5UR(:aUR[*5 URUR:�a/X@:waUR[,5 UR[.5 URU5nU$)	zwQuantize self so its exponent is the same as that of exp.

Similar to self._rescale(exp._exp) but with error checking.
Trzquantize with one INFz)target exponent out of bounds in quantizer�z9exponent of quantize result too large for current contextr2z7quantize result has too many digits for current context)rrrur�r�r�rr�r
rer�rwrJrKrDr�rvrQr�rLr}rrr
)r7r�rur8rOr�s      r/r��Decimal.quantize�	sP��
�S�$�/���?� �l�G����'�'�H����s����"�"�3�0�C���
���� � �D�$4�$4�$6�$6��?�?�$�$��)9�)9�);�);�"�4�=�(��+�+�,<�(?�A�A��
�
��3�8�8�;�w�|�|�;��'�'�(8�>�@�
@��"�4�:�:�s�C�H�H�=�C��8�8�G�$�$��
�
��
��<�<�'��'�'�(8�(c�e�
e��8�8�#�a�'�'�,�,�6��'�'�(8�(a�c�
c��m�m�C�H�H�h�/���<�<�>�G�L�L�(��'�'�(8�(c�e�
e��s�x�x�=�7�<�<�'��'�'�(8�(a�c�
c��3�<�<�>�G�L�L�0�� � ��+��8�8�d�i�i���{��$�$�W�-�� � ��)��h�h�w����
r1c�6�[USS9nUR(dUR(aUUR5=(a UR5=(d' UR5=(a UR5$URUR:H$)a
Return True if self and other have the same exponent; otherwise
return False.

If either operand is a special value, the following rules are used:
   * return True if both operands are infinities
   * return True if both operands are NaNs
   * otherwise, return False.
Tr)rr�r�is_infiniter�r�s   r/�same_quantum�Decimal.same_quantum�	sm���u�d�3�����u�0�0��K�K�M�4�e�l�l�n�?��$�$�&�>�5�+<�+<�+>�
@��y�y�E�J�J�&�&r1c�P�UR(a[U5$U(d[URSU5$URU:�a4[URUR
SURU-
--U5$[
UR
5UR-U-
nUS:a[URSUS-
5nSnURUnU"X5nUR
SU=(d SnUS:Xa[[U5S-5n[URXa5$)a;Rescale self so that the exponent is exp, either by padding with zeros
or by truncating digits, using the given rounding mode.

Specials are returned without change.  This operation is
quiet: it raises no flags, and uses no information from the
context.

exp = exp to scale to (an integer)
rounding = rounding mode
r�r(r_r2N)
r�rrJrKr�rLr�r�r�r�)r7r�rur��
this_functionr�r�s       r/rQ�Decimal._rescale�	s������4�=� ��#�D�J�J��S�9�9��9�9���#�D�J�J�(,�	�	�C����S��4I�(I�3�P�
P�
�T�Y�Y��$�)�)�+�c�1���A�:�#�D�J�J��S��U�;�D��F��4�4�X�>�
���-���	�	�'�6�"�)�c���a�<���E�
�1��%�E���
�
�E�7�7r1c�J�US::a[S5eUR(dU(d[U5$URUR	5S-U-
U5nUR	5UR	5:wa&URUR	5S-U-
U5nU$)z�Round a nonzero, nonspecial Decimal to a fixed number of
significant figures, using the given rounding mode.

Infinities, NaNs and zeros are returned unaltered.

This operation is quiet: it raises no flags, and uses no
information from the context.

r(z'argument should be at least 1 in _roundr2)r�r�rrQr�)r7�placesrurOs    r/�_round�Decimal._round

s����Q�;��F�G�G����4��4�=� ��m�m�D�M�M�O�A�-�f�4�h�?��
�<�<�>�T�]�]�_�,��,�,�s�|�|�~�a�/��6��A�C��
r1c��UR(a#URUS9nU(aU$[U5$URS:�a[U5$U(d[	UR
SS5$Uc
[
5nUcURnURSU5nX0:waUR[5 UR[5 U$)a&Rounds to a nearby integer.

If no rounding mode is specified, take the rounding mode from
the context.  This method raises the Rounded and Inexact flags
when appropriate.

See also: to_integral_value, which does exactly the same as
this method except that it doesn't raise Inexact or Rounded.
r�r(r�)r�r�rr�rJrKrrurQr�rr
�r7rur8rOs    r/�to_integral_exact�Decimal.to_integral_exact!
s�������"�"�7�"�3�C���
��4�=� ��9�9��>��4�=� ��#�D�J�J��Q�7�7��?� �l�G����'�'�H��m�m�A�x�(���;�� � ��)����W�%��
r1c��Uc
[5nUcURnUR(a#URUS9nU(aU$[	U5$UR
S:�a[	U5$UR
SU5$)z@Rounds to the nearest integer, without raising inexact, rounded.r�r()rrur�r�rr�rQr4s    r/r��Decimal.to_integral_value>
ss���?� �l�G����'�'�H�����"�"�7�"�3�C���
��4�=� ��9�9��>��4�=� ��=�=��H�-�-r1c�r�Uc
[5nUR(aHURUS9nU(aU$UR5(aURS:Xa[U5$U(d5[
URSURS-5nURU5$URS:XaUR[S5$URS-n[U5nURS-	nURS-(a+URS-n[UR 5S-	S-nO'URn[UR 5S-S-	nX7-
nUS:�aUSU--nS	n	O[#USU*-5upjU
(+n	XX-nSU-nXk-nX�::aO	X�-S-	nMU	=(a X�-U:Hn	U	(aUS:�a	USU--nO	USU*--nXX-
nOUS
-S:XaUS-
n[
S[%U5U5nUR'5nUR)[*5n
URU5nX�lU$)zReturn the square root of self.r�r(r�r�r2zsqrt(-x), x > 0rr�Tr�)rr�r�r�rKrrJr�rDr�r
rvr�r�r�r�rLrfr��
_shallow_copy�
_set_roundingrru)r7r8rOrv�opr6�c�lrgrrhrIrnrus              r/�sqrt�Decimal.sqrtQ
s(���?� �l�G�����"�"�7�"�3�C���
����!�!�d�j�j�A�o��t�}�$��"�4�:�:�s�D�I�I��N�C�C��8�8�G�$�$��:�:��?��'�'�(8�:K�L�L�,�|�|�A�~���d�^���F�F�a�K��
�6�6�A�:������A��T�Y�Y��1�$��)�A����A��D�I�I��q� �A�%�A�����A�:�
��e��O�A��E�!�!�S�5�&�[�1�L�A�!�M�E�	�
��
��H�����A��v���E�Q�J����"�!�#��(�����z��b�%�i����R�%��Z���
�J�A��1�u��z��Q����q�#�a�&�!�,���'�'�)���(�(��9���h�h�w���#���
r1c���[USS9nUc
[5nUR(dUR(ayUR5nUR5nU(dU(aKUS:XaUS:XaUR	U5$US:XaUS:XaUR	U5$URX5$UR
U5nUS:XaURU5nUS:XaUnOUnUR	U5$)z�Returns the larger value.

Like max(self, other) except if one is not a number, returns
NaN (and signals if one is sNaN).  Also rounds.
Trr2r(r��rrr�r�rDr�r��
compare_total�r7r�r8�sn�onr=rOs       r/rP�Decimal.max�
s����u�d�3���?� �l�G����u�0�0�����B�����B��R���7�r�Q�w��9�9�W�-�-���7�r�Q�w� �:�:�g�.�.��'�'��7�7��I�I�e�����6��"�"�5�)�A���7��C��C��x�x�� � r1c���[USS9nUc
[5nUR(dUR(ayUR5nUR5nU(dU(aKUS:XaUS:XaUR	U5$US:XaUS:XaUR	U5$URX5$UR
U5nUS:XaURU5nUS:XaUnOUnUR	U5$)z�Returns the smaller value.

Like min(self, other) except if one is not a number, returns
NaN (and signals if one is sNaN).  Also rounds.
Trr2r(r�rBrDs       r/r)�Decimal.min�
s����u�d�3���?� �l�G����u�0�0�����B�����B��R���7�r�Q�w��9�9�W�-�-���7�r�Q�w� �:�:�g�.�.��'�'��7�7��I�I�e�����6��"�"�5�)�A���7��C��C��x�x�� � r1c��UR(agURS:�agURURSnUS[U5-:H$)z"Returns whether self is an integerFr(TNr�)r�r�rLr�)r7�rests  r/r��Decimal._isintegersC�������9�9��>���y�y�����$���s�3�t�9�}�$�$r1c�p�U(aURS:�agURSUR-S;$)z:Returns True if self is even.  Assumes self is an integer.r(Tr�r�)r�rLr�s r/r��Decimal._iseven	s.���t�y�y�1�}���y�y��D�I�I��&�'�1�1r1c�n�UR[UR5-S-
$![a gf=f)z$Return the adjusted exponent of selfr2r()r�r�rLr�r�s r/r��Decimal.adjusteds5��	��9�9�s�4�9�9�~�-��1�1���	��	�s�$'�
4�4c��U$)z�Returns the same Decimal object.

As we do not have different encodings for the same number, the
received object already is in its canonical form.
r-r�s r/�	canonical�Decimal.canonicals	���r1c�h�[USS9nURX5nU(aU$URXS9$)z�Compares self to the other operand numerically.

It's pretty much like compare(), but all NaNs signal, with signaling
NaNs taking precedence over quiet NaNs.
Trr�)rr�rrs    r/�compare_signal�Decimal.compare_signals9���u��5���&�&�u�6����J��|�|�E�|�3�3r1c���[USS9nUR(aUR(d[$UR(dUR(a[$URnUR	5nUR	5nU(dU(a�XE:Xax[UR5UR4n[UR5UR4nXg:aU(a[$[$Xg:�aU(a[$[$[$U(a1US:Xa[$US:Xa[$US:Xa[$US:Xa[$O0US:Xa[$US:Xa[$US:Xa[$US:Xa[$X:a[$X:�a[$URUR:aU(a[$[$URUR:�aU(a[$[$[$)z�Compares self to other using the abstract representations.

This is not like the standard compare, which use their numerical
value. Note that a total ordering is defined for all possible abstract
representations.
Trr2r�)	rrK�_NegativeOnerr�r�rL�_Zeror�)r7r�r8r\�self_nan�	other_nan�self_key�	other_keys        r/rC�Decimal.compare_total+s����u�d�3���:�:�e�k�k����z�z�e�k�k��K��z�z���;�;�=���L�L�N�	��y��$��t�y�y�>�4�9�9�4����
�
�O�U�Z�Z�7�	��'��#��+�+��'��+�+�#������q�=�'�'���>��K��q�=�'�'���>��K�"��q�=��K���>�'�'��q�=��K���>�'�'��<����<��K��9�9�u�z�z�!����#�#��9�9�u�z�z�!��#�#����r1c�x�[USS9nUR5nUR5nURU5$)z�Compares self to other using abstract repr., ignoring sign.

Like compare_total, but with operand's sign ignored and assumed to be 0.
Tr)rrBrC)r7r�r8r��os     r/�compare_total_mag�Decimal.compare_total_magts6��
�u�d�3���M�M�O���N�N������q�!�!r1c�Z�[SURURUR5$)z'Returns a copy with the sign set to 0. r()rJrLr�r�r�s r/rB�Decimal.copy_abss!����4�9�9�d�i�i��9I�9I�J�Jr1c���UR(a,[SURURUR5$[SURURUR5$)z&Returns a copy with the sign inverted.r(r2)rKrJrLr�r�r�s r/rC�Decimal.copy_negate�sG���:�:�#�A�t�y�y�$�)�)�T�=M�=M�N�N�#�A�t�y�y�$�)�)�T�=M�=M�N�Nr1c��[USS9n[URURURUR
5$)z$Returns self with the sign of other.Tr)rrJrKrLr�r�r�s   r/�	copy_sign�Decimal.copy_sign�s6���u�d�3������T�Y�Y� $�	�	�4�+;�+;�=�	=r1c���Uc
[5nURUS9nU(aU$UR5S:Xa[$U(d[$UR5S:Xa[U5$URnUR5nURS:XaDU[[URS-S-55:�a[SSURS-5nGOLURS:XaLU[[UR5*S-S-55:�a[SSUR5S-
5nO�URS:Xa!XC*:a[SSSUS-
--S-U*5nO�URS:Xa!XC*S-
:a[SSUS--U*S-
5nO�[U5nURUR pvUR"S:XaU*nSn[%XgX8-5up�U	S	S
[[U	55U-
S-
---(aOUS-
nM@[S[U	5U
5nUR'5nUR)[*5nUR-U5nX�lU$)zReturns e ** self.r�r�r2r(r�r_r�rtr�r)rr�r�rYrrrvr�rKr�r�rwrJrer�r�r�r\�_dexpr:r;rrDru)r7r8rOr��adjr<r=r6rr�r�rus            r/r��Decimal.exp�s6���?� �l�G����w��/����J������#��L���K������"��4�=� �
�L�L���m�m�o���:�:��?�s�S��g�l�l�1�n�a�-?�)@�%A�A�"�1�c�7�<�<��>�:�C�
�Z�Z�1�_��s�3�����0@��0B�A�/E�+F�'G�!G�"�1�c�7�=�=�?�1�+<�=�C�
�Z�Z�1�_��r��"�1�c�C��1��I�o��&;�a�R�@�C�
�Z�Z�1�_��r�!�t��"�1�c�1�Q�3�i�!��A��6�C��$��B��6�6�2�6�6�q��w�w�!�|��B��
�E��"�1���1�
���A�b�3�s�5�z�?�1�#4�Q�#6�7�7�8����
��	�#�1�c�%�j�#�6�C��'�'�)���(�(��9���h�h�w���#���
r1c��g)z�Return True if self is canonical; otherwise return False.

Currently, the encoding of a Decimal instance is always
canonical, so this method returns True for any Decimal.
Tr-r�s r/�is_canonical�Decimal.is_canonical�s��r1c�$�UR(+$)z�Return True if self is finite; otherwise return False.

A Decimal instance is considered finite if it is neither
infinite nor a NaN.
)r�r�s r/�	is_finite�Decimal.is_finite�s���#�#�#�#r1c� �URS:H$)z8Return True if self is infinite; otherwise return False.r��r�r�s r/r)�Decimal.is_infinite�����y�y�C��r1c� �URS;$)z>Return True if self is a qNaN or sNaN; otherwise return False.r�rur�s r/r�Decimal.is_nan�s���y�y�J�&�&r1c��UR(dU(dgUc
[5nURUR5:*$)z?Return True if self is a normal number; otherwise return False.F)r�rr}r�r>s  r/�	is_normal�Decimal.is_normal�s1�����4���?� �l�G��|�|�t�}�}��.�.r1c� �URS:H$)z;Return True if self is a quiet NaN; otherwise return False.rIrur�s r/r��Decimal.is_qnan�rwr1c� �URS:H$)z8Return True if self is negative; otherwise return False.r2)rKr�s r/�	is_signed�Decimal.is_signed�s���z�z�Q��r1c� �URS:H$)z?Return True if self is a signaling NaN; otherwise return False.r�rur�s r/r��Decimal.is_snanrwr1c��UR(dU(dgUc
[5nUR5UR:$)z9Return True if self is subnormal; otherwise return False.F)r�rr�r}r>s  r/�is_subnormal�Decimal.is_subnormals1�����4���?� �l�G��}�}�����-�-r1c�P�UR(+=(a URS:H$)z6Return True if self is a zero; otherwise return False.r�r�r�s r/�is_zero�Decimal.is_zeros���#�#�#�8��	�	�S�(8�8r1c���UR[UR5-S-
nUS:�a[[US-S-55S-
$US::a [[SU-
S-S-55S-
$[	U5nUR
URpCUS:Xa9[USU*--
5n[U5n[U5[U5-
XV:-
$U[[SU*-U-
55-S-
$)z�Compute a lower bound for the adjusted exponent of self.ln().
In other words, compute r such that self.ln() >= 10**r.  Assumes
that self is finite and positive and that self != 1.
r2�rrr�r(�r�r�rLr�r�r�r��r7rlr<r=r6�num�dens       r/�
_ln_exp_bound�Decimal._ln_exp_bounds����i�i�#�d�i�i�.�(�1�,���!�8��s�3�r�6�2�:��'�!�+�+��"�9��s�B�s�F�B�;��?�+�,�q�0�0�
�d�^���v�v�r�v�v�1��!�8��a��Q�B��h�-�C��a�&�C��s�8�c�#�h�&�#�)�4�4��3�s�2��r�6�A�:��'�'�!�+�+r1c
���Uc
[5nURUS9nU(aU$U(d[$UR5S:Xa[$U[
:Xa[$URS:XaUR[S5$[U5nURURpTURnX`R5-
S-n[XEU5nUSS[![#[%U555U-
S-
---(aOUS-
nME['[US:5[#[%U55U*5nUR)5nUR+[,5n	UR/U5nX�lU$)	z/Returns the natural (base e) logarithm of self.r�r2zln of a negative valuer�r�rr�r()rr��_NegativeInfinityr��	_InfinityrrYrKr�r
r�r�r�rvr��_dlogr�r�r�rJr:r;rrDru�
r7r8rOr<r=r6r�r0r�rus
          r/�ln�
Decimal.ln,sd���?� �l�G����w��/����J��$�$������"����4�<��L��:�:��?��'�'�(8�(@�B�
B��d�^���v�v�r�v�v�1��L�L���'�'�)�)�A�-����!��'�E���"�s�3�s�5�z�?�3�A�5�a�7�8�8�9���a�K�F���s�5��7�|�S��U��_�v�g�F���'�'�)���(�(��9���h�h�w���#���
r1c���UR[UR5-S-
nUS:�a[[U55S-
$US::a[[SU-
55S-
$[	U5nUR
URpCUS:Xa?[USU*--
5n[SU-5n[U5[U5-
XV:-
S-$[SU*-U-
5n[U5U-US:-
S-
$)	z�Compute a lower bound for the adjusted exponent of self.log10().
In other words, find r such that self.log10() >= 10**r.
Assumes that self is finite and positive and that self != 1.
r2rr�r(r��r��231r�r�s       r/r�Decimal._log10_exp_bound^s����i�i�#�d�i�i�.�(�1�,���!�8��s�3�x�=��?�"��"�9��s�2�c�6�{�#�A�%�%�
�d�^���v�v�r�v�v�1��!�8��a��Q�B��h�-�C��c�!�e�*�C��s�8�c�#�h�&�#�)�4�q�8�8��"�q�b�&��(�m���3�x�!�|�s�U�{�+�a�/�/r1c
��Uc
[5nURUS9nU(aU$U(d[$UR5S:Xa[$UR
S:XaUR
[S5$URSS:Xa[URSSS[UR5S-
-:Xa/[UR[UR5-S-
5nO�[U5nURURpTURnX`R!5-
S-n[#XEU5nUS	S
[[%['U555U-
S-
---(aOUS-
nME[)[US:5[%['U55U*5nUR+5nUR-[.5n	UR1U5nX�lU$)z&Returns the base 10 logarithm of self.Nr�r2zlog10 of a negative valuer(r_r�r�r�rr�)rr�r�r�r�rKr�r
rLr�rr�r�r�r�rvr�_dlog10r�r�rJr:r;rrDrur�s
          r/�log10�
Decimal.log10|s����?� �l�G����w��/����J��$�$������"����:�:��?��'�'�(8�(C�E�
E��9�9�Q�<�3��4�9�9�Q�R�=�C��T�Y�Y��!�9K�4L�#L��$�)�)�c�$�)�)�n�4�q�8�9�C��$��B��6�6�2�6�6�q����A��,�,�.�.�q�0�F����f�-���A�b�3�s�3�u�:��#7��#9�!�#;�<�<�=���!����#�3�u�Q�w�<��S��Z��6�'�J�C��'�'�)���(�(��9���h�h�w���#���
r1c��URUS9nU(aU$Uc
[5nUR5(a[$U(dUR	[
SS5$[
UR55nURU5$)a$Returns the exponent of the magnitude of self's MSD.

The result is the integer which is the exponent of the magnitude
of the most significant digit of self (as though it were truncated
to a single digit while maintaining the value of that digit and
without limiting the resulting exponent).
r�zlogb(0)r2)	r�rr�r�r�rrr�rDrEs   r/�logb�Decimal.logb�s}�����w��/����J��?� �l�G����������'�'��	�1�E�E�
�d�m�m�o�&���x�x�� � r1c�|�URS:wdURS:wagURHnUS;dM g g)z�Return True if self is a logical operand.

For being logical, it must be a finite number with a sign of 0,
an exponent of 0, and a coefficient whose digits must all be
either 0 or 1.
r(F�01T)rKr�rL)r7�digs  r/�
_islogical�Decimal._islogical�s9���:�:��?�d�i�i�1�n���9�9�C��$����r1c��UR[U5-
nUS:�a	SU-U-nOUS:aX!R*SnUR[U5-
nUS:�aSU-U-nX#4$US:aX1R*SnX#4$)Nr(r�)rvr�)r7r8�opa�opb�difs     r/�
_fill_logical�Decimal._fill_logical�s����l�l�S��X�%����7��c�'�C�-�C�
�1�W��|�|�m�n�%�C��l�l�S��X�%����7��c�'�C�-�C��x���1�W��|�|�m�n�%�C��x�r1c���Uc
[5n[USS9nUR5(aUR5(dUR[5$URX RUR5up4SR[X45VVs/sH%upV[[U5[U5-5PM' snn5n[SURS5=(d SS5$s snnf)z;Applies an 'and' operation between self and other's digits.Trr�r(r��
rrr�r�r
r�rLr��zipr�r�rJr��r7r�r8r�r�r�br�s        r/�logical_and�Decimal.logical_and�����?� �l�G��u�d�3����� � ��(8�(8�(:�(:��'�'�(8�9�9��'�'����E�J�J�G�
������C��E����#�c�!�f�S��V�m�,��E�F����6�=�=��#5�#<��a�@�@��F��,C1
c�p�Uc
[5nUR[SSUR-S5U5$)zInvert all its digits.r(r_)r�logical_xorrJrvr>s  r/�logical_invert�Decimal.logical_invert�s9���?� �l�G���� 0��3�w�|�|�3C�A� F� '�)�	)r1c���Uc
[5n[USS9nUR5(aUR5(dUR[5$URX RUR5up4SR[X45VVs/sH%upV[[U5[U5-5PM' snn5n[SURS5=(d SS5$s snnf)z:Applies an 'or' operation between self and other's digits.Trr�r(r�r�r�s        r/�
logical_or�Decimal.logical_or
r�r�c���Uc
[5n[USS9nUR5(aUR5(dUR[5$URX RUR5up4SR[X45VVs/sH%upV[[U5[U5-5PM' snn5n[SURS5=(d SS5$s snnf)z;Applies an 'xor' operation between self and other's digits.Trr�r(r�r�r�s        r/r��Decimal.logical_xor
r�r�c�&�[USS9nUc
[5nUR(dUR(ayUR5nUR5nU(dU(aKUS:XaUS:XaUR	U5$US:XaUS:XaUR	U5$URX5$UR
5RUR
55nUS:XaURU5nUS:XaUnOUnUR	U5$�z8Compares the values numerically with their sign ignored.Trr2r(r��	rrr�r�rDr�rBr�rCrDs       r/�max_mag�Decimal.max_mag"
s����u�d�3���?� �l�G����u�0�0�����B�����B��R���7�r�Q�w��9�9�W�-�-���7�r�Q�w� �:�:�g�.�.��'�'��7�7��M�M�O� � ����!1�2����6��"�"�5�)�A���7��C��C��x�x�� � r1c�&�[USS9nUc
[5nUR(dUR(ayUR5nUR5nU(dU(aKUS:XaUS:XaUR	U5$US:XaUS:XaUR	U5$URX5$UR
5RUR
55nUS:XaURU5nUS:XaUnOUnUR	U5$r�r�rDs       r/�min_mag�Decimal.min_mag@
s����u�d�3���?� �l�G����u�0�0�����B�����B��R���7�r�Q�w��9�9�W�-�-���7�r�Q�w� �:�:�g�.�.��'�'��7�7��M�M�O� � ����!1�2����6��"�"�5�)�A���7��C��C��x�x�� � r1c���Uc
[5nURUS9nU(aU$UR5S:Xa[$UR5S:Xa([	SSUR
-UR
55$UR5nUR[5 UR5 URU5nX0:waU$UR[	SSUR5S-
5U5$)z=Returns the largest representable number smaller than itself.r�r�r2r(rtr_)rr�r�r�rJrvr�r�r;r�_ignore_all_flagsrDrYre�r7r8rO�new_selfs    r/�
next_minus�Decimal.next_minus^
s����?� �l�G����w��/����J������#�$�$������"�#�A�s�7�<�<�'7�����H�H��,�,�.�����k�*��!�!�#��9�9�W�%�����O��|�|�,�Q��W�]�]�_�Q�5F�G�#�%�	%r1c���Uc
[5nURUS9nU(aU$UR5S:Xa[$UR5S:Xa([	SSUR
-UR
55$UR5nUR[5 UR5 URU5nX0:waU$UR[	SSUR5S-
5U5$)z=Returns the smallest representable number larger than itself.r�r2r�rtr(r_)rr�r�r�rJrvr�r�r;rr�rDrVrer�s    r/�	next_plus�Decimal.next_plusu
s����?� �l�G����w��/����J������"��������#�#�A�s�7�<�<�'7�����H�H��,�,�.�����m�,��!�!�#��9�9�W�%�����O��|�|�,�Q��W�]�]�_�Q�5F�G�#�%�	%r1c���[USS9nUc
[5nURX5nU(aU$URU5nUS:XaUR	U5$US:XaURU5nOUR
U5nUR5(aMUR[SUR5 UR[5 UR[5 U$UR5UR:apUR[5 UR[ 5 UR[5 UR[5 U(dUR["5 U$)a[Returns the number closest to self, in the direction towards other.

The result is the closest representable number to self
(excluding self) that is in the direction towards other,
unless both have the same value.  If the two operands are
numerically equal, then the result is a copy of self with the
sign set to be the same as the sign of other.
Trr(r�z Infinite result from next_toward)rrr�r�rhr�r�r�r�rrKrr
r�r}rrr	)r7r�r8rO�
comparisons     r/�next_toward�Decimal.next_toward�
s.���u�d�3���?� �l�G����u�.����J��Y�Y�u�%�
���?��>�>�%�(�(�����.�.��)�C��/�/�'�*�C��?�?���� � ��!C�!$���
,�
� � ��)�� � ��)��
��\�\�^�g�l�l�
*�� � ��+�� � ��+�� � ��)�� � ��)���$�$�W�-��
r1c�t�UR5(agUR5(agUR5nUS:XagUS:XagUR5(aUR(aggUc
[5nUR
US	9(aUR(ag
gUR(agg
)z�Returns an indication of the class of self.

The class is one of the following strings:
  sNaN
  NaN
  -Infinity
  -Normal
  -Subnormal
  -Zero
  +Zero
  +Subnormal
  +Normal
  +Infinity
r�r3r2z	+Infinityr�z	-Infinityz-Zeroz+Zeror�z
-Subnormalz
+Subnormalz-Normalz+Normal)r�r�r�r�rKrr�)r7r8�infs   r/�number_class�Decimal.number_class�
s����<�<�>�>���<�<�>�>����� ���!�8���"�9���<�<�>�>��z�z����?� �l�G����W��-��z�z�#�#��:�:��r1c��[S5$)z'Just returns 10, as this is Decimal, :)rr�r�s r/�radix�
Decimal.radix�
s���r�{�r1c��Uc
[5n[USS9nURX5nU(aU$URS:waUR	[
5$UR*[U5s=::aUR::dO UR	[
5$UR5(a[U5$[U5nURnUR[U5-
nUS:�a	SU-U-nOUS:aXV*SnXTSUSU-n[URURS5=(d SUR5$)z5Returns a rotated copy of self, value-of-other times.NTrr(r��rrr�r�r�r
rvr�r�rrLr�rJrKr�)r7r�r8rO�torot�rotdig�topad�rotateds        r/�rotate�Decimal.rotate�
s$���?� �l�G��u�d�3�����u�.����J��:�:��?��'�'�(8�9�9����
��U��;�w�|�|�;��'�'�(8�9�9�������4�=� ��E�
���������s�6�{�*���1�9���Y��'�F�
�Q�Y��F�G�_�F���.�6�&�5�>�1����
�
� '���s� 3� :�s�D�I�I�G�	Gr1c�L�Uc
[5n[USS9nURX5nU(aU$URS:waUR	[
5$SURUR--nSURUR--nU[U5s=::aU::dO UR	[
5$UR5(a[U5$[URURUR[U5-5nURU5nU$)z>Returns self operand after adding the second value to its exp.Trr(rr�)rrr�r�r�r
rwrvr�r�rrJrKrLrD)r7r�r8rO�liminf�limsupr�s       r/�scaleb�Decimal.scaleb	s����?� �l�G��u�d�3�����u�.����J��:�:��?��'�'�(8�9�9��w�|�|�g�l�l�2�3���w�|�|�g�l�l�2�3���#�e�*�.��.��'�'�(8�9�9�������4�=� ��T�Z�Z����D�I�I��E�
�4J�K��
�F�F�7�O���r1c��Uc
[5n[USS9nURX5nU(aU$URS:waUR	[
5$UR*[U5s=::aUR::dO UR	[
5$UR5(a[U5$[U5nURnUR[U5-
nUS:�a	SU-U-nOUS:aXV*SnUS:aUSUnOUSU--nXrR*Sn[URURS5=(d SUR5$)z5Returns a shifted copy of self, value-of-other times.NTrr(r�r�)r7r�r8rOr�r�r��shifteds        r/rg�
Decimal.shift"s@���?� �l�G��u�d�3�����u�.����J��:�:��?��'�'�(8�9�9����
��U��;�w�|�|�;��'�'�(8�9�9�������4�=� ��E�
���������s�6�{�*���1�9���Y��'�F�
�Q�Y��F�G�_�F��1�9��V�e�n�G��s�5�y�(�G��|�|�m�n�-�G���
�
�$+�N�N�3�$7�$>�3��	�	�K�	Kr1c�2�UR[U544$r,)�	__class__r�r�s r/�
__reduce__�Decimal.__reduce__Is������T���-�-r1c�^�[U5[LaU$UR[U55$r,��typerr�r�r�s r/�__copy__�Decimal.__copy__L�&����:�� ��K��~�~�c�$�i�(�(r1c�^�[U5[LaU$UR[U55$r,r�)r7�memos  r/�__deepcopy__�Decimal.__deepcopy__Qr�r1c�\�Uc
[5n[XS9nUR(aI[URU5n[UR
55nUSS:XaUS-
n[XVU5$UScSS/URUS'USS:Xa.[URURURS-5nURnUSnUboUSS	;aURUS
-U5nOPUSS;aURU*U5nO3USS;a*[UR5U:�aURX�5nU(d+URS
:�aUSS;aURS
U5nU(dUS(aUR(aS
n	OURn	UR[UR5-n
USS	;aU(d	UbS
U-
nO3S
nO0USS;aU
nO$USS;aURS
::a	U
S:�aU
nOS
nWS
:aSnSU*-UR-n
OkU[UR5:�a+URSU[UR5-
--nSn
O'URSU=(d SnURUSn
X�-
n[!X�X�U5$)aLFormat a Decimal instance according to the given specifier.

The specifier should be a standard format specifier, with the
form described in PEP 3101.  Formatting types 'e', 'E', 'f',
'F', 'g', 'G', 'n' and '%' are supported.  If the formatting
type is omitted it defaults to 'g' or 'G', depending on the
value of context.capitals.
N)�_localeconvr��%�g�Gr��	precision�eEr2zfF%�gGr(�no_neg_0r4r�r�)r�_parse_format_specifierr��_format_signrKr�rB�
_format_alignr~rJrLr�rur1rQr��_format_number)r7�	specifierr8r��specr\�bodyrur�
adjusted_signr9r:r�r�r�s               r/�
__format__�Decimal.__format__Xs����?� �l�G�&�y�J�������
�
�D�1�D��t�}�}��'�D��F�|�s�"����� ��T�2�2���<����:�g�&6�&6�7�D��L���<�3��#�D�J�J��	�	�4�9�9�Q�;�G�D��#�#����%�	�� ��F�|�t�#��{�{�9�Q�;��9���f���&��}�}�i�Z��:���f���%�#�d�i�i�.�9�*D��{�{�9�7����	�	�A�
�$�v�,�%�*?��=�=��H�-�D���Z�(�T�Z�Z��M� �J�J�M��Y�Y��T�Y�Y��/�
���<�4���I�1��y�=����
�&�\�U�
"�!�H�
�&�\�T�
!��y�y�A�~�*�r�/�%�����a�<��G��X�I�����2�H�
��D�I�I��
&��i�i�#�x��D�I�I��'>�"?�?�G��H��i�i�	��*�1�c�G��y�y���+�H��!���m�h�T�J�Jr1)r�rLr�rK)r�N)NNr,)FN)TN)�r<r=r>r?r@�	__slots__r��classmethodr�r�r�r�r�r�r�r�rr	r
rrrr%r�r/r;r?rFrIrMrV�__radd__rYr\rb�__rmul__rjrprsrzr}r�r�r�r�r�r�r��	__trunc__�propertyr�r�r�r�rMrDr�r�r�r�r�r�r�r��dictr�r�r�r�r�r�r
rrr$r�r*rQr1r5r��to_integralr?rPr)r�r�r�rRrUrCrarBrCrhr�rorrr)rr{r�r�r�r�r�r�r�rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rgr�r�r�rrAr-r1r/rr�s���6�6�I�T@�l�*��*�X
���@�B4�-'�@%�$�%�$�%�)�$(�4O�0�d+�
2/�h7�!�,!�*�,T�l�H�B�4�6�n�H�9!�v�B8�"#�H7��64�I!�V/�89��7��I�
���������$�
�Z�L�'��-�-�+�+�+�#� ��&�*�*�&�"� �	��<6�|
2�
4�*/�XS4�jv?�pV�p4�@�2;�z
'� 8�D�.�:.�"$�K�a�F(!�T !�D%�2���
4�F�R	"�K�O�=�I�V�$� �'�/� �� �.�9�,�20�d0�<1�f!�<��A�")�A�"A�"!�<!�<%�.%�.,�\(�T�G�B�2$K�N.�)�
)�TKr1rc�h�[R[5nXlXlX$lX4lU$)z�Create a decimal instance directly, without any validation,
normalization (e.g. removal of leading zeros) or argument
conversion.

This function is for *internal use only*.
)r�r�rrKrLr�r�)r\�coefficientr��specialr7s     r/rJrJ�s,���>�>�'�"�D��J��I��I����Kr1c�*�\rSrSrSrSrSrSrSrg)r�i�z�Context manager class to support localcontext().

Sets a copy of the supplied context in __enter__() and restores
the previous decimal context in __exit__()
c�.�UR5Ulgr,)r�r�)r7r�s  r/�__init__�_ContextManager.__init__�s��&�+�+�-��r1c�b�[5Ul[UR5 UR$r,)r�
saved_contextrr�r�s r/�	__enter__�_ContextManager.__enter__�s&��'�\����4�#�#�$����r1c�.�[UR5 gr,)rr)r7�t�v�tbs    r/�__exit__�_ContextManager.__exit__�s���4�%�%�&r1)r�rN)	r<r=r>r?r@rrr%rAr-r1r/r�r��s���
.� �'r1r�c� �\rSrSrSrSVSjrSrSrSrSr	S	r
S
rSrSr
S
rSr\rSWSjrSrSrSrSrSrSrSrSXSjrSrSrSrSrSrSrSr Sr!Sr"S r#S!r$S"r%S#r&S$r'S%r(S&r)S'r*S(r+S)r,S*r-S+r.S,r/S-r0S.r1S/r2S0r3S1r4S2r5S3r6S4r7S5r8S6r9S7r:S8r;S9r<S:r=S;r>S<r?S=r@S>rAS?rBS@rCSArDSBrESCrFSDrGSErHSWSFjrISGrJSHrKSIrLSJrMSKrNSLrOSMrPSNrQSOrRSPrSSQrTSRrUSSrVSTrW\WrXSUrYg)Yri�a�Contains the context for a Decimal instance.

Contains:
prec - precision (for use in rounding, division, square roots..)
rounding - rounding type (how you round)
traps - If traps[exception] = 1, then the exception is
                raised when it is caused.  Otherwise, a value is
                substituted in.
flags  - When an exception is caused, flags[exception] is set.
         (Whether or not the trap_enabler is set)
         Should be reset by user of Decimal instance.
Emin -   Minimum exponent
Emax -   Maximum exponent
capitals -      If 1, 1*10^1 is printed as 1E+1.
                If 0, printed as 1e1
clamp -  If 1, change exponents if too high (Default 0)
Nc
��^^�[n
UbUOW
RUlUbUOW
RUlUbUOW
RUlUbUOW
R
UlUbUOW
RUlUbUOW
RUlU	c/UlOX�lTc W
RR5Ul	O>[T[5(d"[U4Sj[T-55Ul	OTUl	Tc [R[S5Ulg[T[5(d"[U4Sj[T-55UlgTUlg![a GNef=f)Nc3�B># �UHo[UT;54v� M g7fr,�r�)�.0r�r�s  �r/�	<genexpr>�#Context.__init__.<locals>.<genexpr>�����M�<L�q�#�a�5�j�/�2�<L���r(c3�B># �UHo[UT;54v� M g7fr,r*)r+r�r�s  �r/r,r-r.r/)r�	NameErrorrvrur}rwr~r�_ignored_flagsr�r�r�rr�fromkeysr�)r7rvrur}rwr~rr�r�r2�dcs       ``  r/r�Context.__init__�s&���
	��B�!�,�D�"�'�'��	�$,�$8��b�k�k��
� �,�D�"�'�'��	� �,�D�"�'�'��	�$,�$8��b�k�k��
�#�/�U�R�X�X��
��!�"$�D��"0���=�������D�J��E�4�(�(��M�H�u�<L�M�M�D�J��D�J��=����x��3�D�J��E�4�(�(��M�H�u�<L�M�M�D�J��D�J��7�	��	�s�E"�"
E0�/E0c��[U[5(d[SU-5eUS:XaX$:�a[SXXB4-5eO6US:XaX#:a[SXXB4-5eOX#:dX$:�a[SXXB4-5e[RXU5$)Nz%s must be an integer�-infz%s must be in [%s, %d]. got: %sr�z%s must be in [%d, %s]. got: %sz%s must be in [%d, %d]. got %s)r�r�r�r�r��__setattr__)r7�namer��vmin�vmaxs     r/�_set_integer_check�Context._set_integer_checks����%��%�%��3�d�:�;�;��6�>��|� �!B�d�RV�E^�!^�_�_��
�U�]��|� �!B�d�RV�E^�!^�_�_���|�u�|� �!A�T�QU�D]�!]�^�^��!�!�$�e�4�4r1c��[U[5(d[SU-5eUHnU[;dM[	SU-5e [HnX2;dM
[	SU-5e [
R
XU5$)Nz%s must be a signal dictz%s is not a valid signal dict)r�rr�r�KeyErrorr�r8)r7r9r�r�s    r/�_set_signal_dict�Context._set_signal_dictsy���!�T�"�"��6��:�;�;��C��(�?��>��B�C�C���C��8��>��B�C�C���!�!�$�a�0�0r1c���US:XaURXSS5$US:XaURXSS5$US:XaURXSS5$US:XaURXSS5$US	:XaURXSS5$US
:Xa.U[;a[SU-5e[R	XU5$US:XdUS
:XaURX5$US:Xa[R	XU5$[
SU-5e)Nrvr2r�r}r7r(rwr~rruz%s: invalid rounding moder�r�r2z.'decimal.Context' object has no attribute '%s')r<�_rounding_modesr�r�r8r@�AttributeError)r7r9r�s   r/r8�Context.__setattr__%s���6�>��*�*�4��5�A�A�
�V�^��*�*�4���B�B�
�V�^��*�*�4��5�A�A�
�Z�
��*�*�4��1�=�=�
�W�_��*�*�4��1�=�=�
�Z�
��O�+� � ;�e� C�D�D��%�%�d�%�8�8�
�W�_�����(�(��5�5�
�%�
%��%�%�d�%�8�8� �@�4�G�I�
Ir1c��[SU-5e)Nz%s cannot be deleted)rD)r7r9s  r/�__delattr__�Context.__delattr__>s���3�d�:�;�;r1c	��URR5VVs/sHupU(dMUPM nnnURR5VVs/sHupU(dMUPM nnnURURUR
URURURURX444$s snnfs snnfr,)
r�r�r�r�rvrur}rwr~r)r7�sigr#r�r�s     r/r��Context.__reduce__Bs���#'�:�:�#3�#3�#5�;�#5�����#5��;�#'�:�:�#3�#3�#5�;�#5�����#5��;�������D�M�M�4�9�9�d�i�i�����
�
�E�:�;�	;��<��;s�
C�C�
C�&Cc��/nURS[U5-5 URR5VVs/sHup#U(dMURPM nnnURSSRU5-S-5 URR5VVs/sHupSU(dMURPM nnnURSSRU5-S-5 SRU5S-$s snnfs snnf)zShow the current context.zrContext(prec=%(prec)d, rounding=%(rounding)s, Emin=%(Emin)d, Emax=%(Emax)d, capitals=%(capitals)d, clamp=%(clamp)dzflags=[�, �]ztraps=[�))r��varsr�r�r<r�r�)r7r�r�r#�namesr"s      r/r/�Context.__repr__Is�����	���#���:��	�)-�
�
�(8�(8�(:�@�(:���a�����(:��@�	����T�Y�Y�u�-�-��3�4�(,�
�
�(8�(8�(:�@�(:���a�����(:��@�	����T�Y�Y�u�-�-��3�4��y�y��|�c�!�!��	A��@s�
D�D�$
D�5Dc�H�URHnSURU'M g)zReset all flags to zeror(N)r��r7�flags  r/r��Context.clear_flagsV����J�J�D� �D�J�J�t��r1c�H�URHnSURU'M g)zReset all traps to zeror(N)r�rTs  r/�clear_traps�Context.clear_traps[rWr1c���[URURURURUR
URURURUR5	nU$)z!Returns a shallow copy from self.)
rrvrur}rwr~rr�r�r2�r7�ncs  r/r:�Context._shallow_copy`sM��
�T�Y�Y��
�
�t�y�y�$�)�)��]�]�D�J�J��
�
�D�J�J��(�(�*���	r1c��[URURURURUR
URURR5URR5UR5	nU$)zReturns a deep copy from self.)rrvrur}rwr~rr�r�r�r2r\s  r/r��Context.copygs\��
�T�Y�Y��
�
�t�y�y�$�)�)��]�]�D�J�J��Z�Z�_�_�&��
�
���(9��(�(�*���	r1c��[RX5nX@R;aU"5R"U/UQ76$SURU'UR
U(dU"5R"U/UQ76$U"U5e)z�Handles an error

If the flag is in _ignored_flags, returns the default response.
Otherwise, it sets the flag, then, if the corresponding
trap_enabler is set, it reraises the exception.  Otherwise, it returns
the default value after setting the flag.
r2)�_condition_mapr�r2r9r�r�)r7�	condition�explanationr.�errors     r/r��Context._raise_errorpsu���"�"�9�8���'�'�'��7�>�>�$�.��.�.���
�
�5���z�z�%� ��;�%�%�d�2�T�2�2��K� � r1c�(�UR"[6$)z$Ignore all flags, if they are raised)�
_ignore_flagsrr�s r/r��Context._ignore_all_flags�s���!�!�8�,�,r1c�R�UR[U5-Ul[U5$)z$Ignore the flags, if they are raised)r2r�)r7r�s  r/rh�Context._ignore_flags�s%�� $�2�2�T�%�[�@����E�{�r1c��U(a#[US[[45(aUSnUHnURR	U5 M  g)z+Stop ignoring the flags, if they are raisedr(N)r�r�r�r2�remove)r7r�rUs   r/�
_regard_flags�Context._regard_flags�s@���Z��a��5��,�7�7��!�H�E��D����&�&�t�,�r1c�L�[URUR-
S-5$)z!Returns Etiny (= Emin - prec + 1)r2)r�r}rvr�s r/re�
Context.Etiny�����4�9�9�t�y�y�(�1�,�-�-r1c�L�[URUR-
S-5$)z,Returns maximum exponent (= Emax - prec + 1)r2)r�rwrvr�s r/r��Context.Etop�rrr1c�*�URnXlU$)a�Sets the rounding type.

Sets the rounding type, and returns the current (previous)
rounding type.  Often used like:

context = context.copy()
# so you don't change the calling context
# if an error occurs in the middle.
rounding = context._set_rounding(ROUND_UP)
val = self.__sub__(other, context=context)
context._set_rounding(rounding)

This will make it round up for that operation.
)ru)r7r�rus   r/r;�Context._set_rounding�s���=�=���
��r1c�t�[U[5(a/XR5:wdSU;aUR[S5$[XS9nUR
5(aF[UR5URUR-
:�aUR[S5$URU5$)z�Creates a new Decimal instance but using self as context.

This method implements the to-number operation of the
IBM Decimal specification.r�zAtrailing or leading whitespace and underscores are not permitted.r�zdiagnostic info too long in NaN)r�r�r�r�rrr�r�rLrvrrD)r7r�r�s   r/�create_decimal�Context.create_decimal�s����c�3���S�I�I�K�%7�3�#�:��$�$�%5�&F�G�
G�
�C�&���8�8�:�:�#�a�f�f�+��	�	�D�J�J�(>�>��$�$�%5�%F�H�
H��v�v�d�|�r1c�N�[RU5nURU5$)aCreates a new Decimal instance from a float but rounding using self
as the context.

>>> context = Context(prec=5, rounding=ROUND_DOWN)
>>> context.create_decimal_from_float(3.1415926535897932)
Decimal('3.1415')
>>> context = Context(prec=5, traps=[Inexact])
>>> context.create_decimal_from_float(3.1415926535897932)
Traceback (most recent call last):
    ...
decimal.Inexact: None

)rr�rD)r7r�r�s   r/�create_decimal_from_float�!Context.create_decimal_from_float�s"��
���q�!���v�v�d�|�r1c�4�[USS9nURUS9$)a�Returns the absolute value of the operand.

If the operand is negative, the result is the same as using the minus
operation on the operand.  Otherwise, the result is the same as using
the plus operation on the operand.

>>> ExtendedContext.abs(Decimal('2.1'))
Decimal('2.1')
>>> ExtendedContext.abs(Decimal('-100'))
Decimal('100')
>>> ExtendedContext.abs(Decimal('101.5'))
Decimal('101.5')
>>> ExtendedContext.abs(Decimal('-101.5'))
Decimal('101.5')
>>> ExtendedContext.abs(-1)
Decimal('1')
Trr�)rrM�r7rs  r/r��Context.abs�s!��$
�1�d�+���y�y��y�&�&r1c�f�[USS9nURX S9nU[La[SU-5eU$)aSReturn the sum of the two operands.

>>> ExtendedContext.add(Decimal('12'), Decimal('7.00'))
Decimal('19.00')
>>> ExtendedContext.add(Decimal('1E+2'), Decimal('1.01E+4'))
Decimal('1.02E+4')
>>> ExtendedContext.add(1, Decimal(2))
Decimal('3')
>>> ExtendedContext.add(Decimal(8), 5)
Decimal('13')
>>> ExtendedContext.add(5, 5)
Decimal('10')
Trr��Unable to convert %s to Decimal)rrVr�r��r7rr�ros    r/�add�Context.add�s>��
�1�d�+��
�I�I�a�I�&������=��A�B�B��Hr1c�6�[URU55$r,)r�rDr~s  r/�_apply�Context._applys���1�6�6�$�<� � r1c�b�[U[5(d[S5eUR5$)z�Returns the same Decimal object.

As we do not have different encodings for the same number, the
received object already is in its canonical form.

>>> ExtendedContext.canonical(Decimal('2.50'))
Decimal('2.50')
z,canonical requires a Decimal as an argument.)r�rr�rRr~s  r/rR�Context.canonicals)���!�W�%�%��J�K�K��{�{�}�r1c�4�[USS9nURX S9$)a�Compares values numerically.

If the signs of the operands differ, a value representing each operand
('-1' if the operand is less than zero, '0' if the operand is zero or
negative zero, or '1' if the operand is greater than zero) is used in
place of that operand for the comparison instead of the actual
operand.

The comparison is then effected by subtracting the second operand from
the first and then returning a value according to the result of the
subtraction: '-1' if the result is less than zero, '0' if the result is
zero or negative zero, or '1' if the result is greater than zero.

>>> ExtendedContext.compare(Decimal('2.1'), Decimal('3'))
Decimal('-1')
>>> ExtendedContext.compare(Decimal('2.1'), Decimal('2.1'))
Decimal('0')
>>> ExtendedContext.compare(Decimal('2.1'), Decimal('2.10'))
Decimal('0')
>>> ExtendedContext.compare(Decimal('3'), Decimal('2.1'))
Decimal('1')
>>> ExtendedContext.compare(Decimal('2.1'), Decimal('-3'))
Decimal('1')
>>> ExtendedContext.compare(Decimal('-3'), Decimal('2.1'))
Decimal('-1')
>>> ExtendedContext.compare(1, 2)
Decimal('-1')
>>> ExtendedContext.compare(Decimal(1), 2)
Decimal('-1')
>>> ExtendedContext.compare(1, Decimal(2))
Decimal('-1')
Trr�)rr�r7rr�s   r/r�Context.compares"��B
�1�d�+���y�y��y�)�)r1c�4�[USS9nURX S9$)a8Compares the values of the two operands numerically.

It's pretty much like compare(), but all NaNs signal, with signaling
NaNs taking precedence over quiet NaNs.

>>> c = ExtendedContext
>>> c.compare_signal(Decimal('2.1'), Decimal('3'))
Decimal('-1')
>>> c.compare_signal(Decimal('2.1'), Decimal('2.1'))
Decimal('0')
>>> c.flags[InvalidOperation] = 0
>>> print(c.flags[InvalidOperation])
0
>>> c.compare_signal(Decimal('NaN'), Decimal('2.1'))
Decimal('NaN')
>>> print(c.flags[InvalidOperation])
1
>>> c.flags[InvalidOperation] = 0
>>> print(c.flags[InvalidOperation])
0
>>> c.compare_signal(Decimal('sNaN'), Decimal('2.1'))
Decimal('NaN')
>>> print(c.flags[InvalidOperation])
1
>>> c.compare_signal(-1, 2)
Decimal('-1')
>>> c.compare_signal(Decimal(-1), 2)
Decimal('-1')
>>> c.compare_signal(-1, Decimal(2))
Decimal('-1')
Trr�)rrUr�s   r/rU�Context.compare_signal7s%��@
�1�d�+�������0�0r1c�8�[USS9nURU5$)a{Compares two operands using their abstract representation.

This is not like the standard compare, which use their numerical
value. Note that a total ordering is defined for all possible abstract
representations.

>>> ExtendedContext.compare_total(Decimal('12.73'), Decimal('127.9'))
Decimal('-1')
>>> ExtendedContext.compare_total(Decimal('-127'),  Decimal('12'))
Decimal('-1')
>>> ExtendedContext.compare_total(Decimal('12.30'), Decimal('12.3'))
Decimal('-1')
>>> ExtendedContext.compare_total(Decimal('12.30'), Decimal('12.30'))
Decimal('0')
>>> ExtendedContext.compare_total(Decimal('12.3'),  Decimal('12.300'))
Decimal('1')
>>> ExtendedContext.compare_total(Decimal('12.3'),  Decimal('NaN'))
Decimal('-1')
>>> ExtendedContext.compare_total(1, 2)
Decimal('-1')
>>> ExtendedContext.compare_total(Decimal(1), 2)
Decimal('-1')
>>> ExtendedContext.compare_total(1, Decimal(2))
Decimal('-1')
Tr)rrCr�s   r/rC�Context.compare_totalZs��4
�1�d�+�����q�!�!r1c�8�[USS9nURU5$)z�Compares two operands using their abstract representation ignoring sign.

Like compare_total, but with operand's sign ignored and assumed to be 0.
Tr)rrar�s   r/ra�Context.compare_total_magws!��

�1�d�+���"�"�1�%�%r1c�6�[USS9nUR5$)z�Returns a copy of the operand with the sign set to 0.

>>> ExtendedContext.copy_abs(Decimal('2.1'))
Decimal('2.1')
>>> ExtendedContext.copy_abs(Decimal('-100'))
Decimal('100')
>>> ExtendedContext.copy_abs(-1)
Decimal('1')
Tr)rrBr~s  r/rB�Context.copy_abss��
�1�d�+���z�z�|�r1c�,�[USS9n[U5$)z�Returns a copy of the decimal object.

>>> ExtendedContext.copy_decimal(Decimal('2.1'))
Decimal('2.1')
>>> ExtendedContext.copy_decimal(Decimal('-1.00'))
Decimal('-1.00')
>>> ExtendedContext.copy_decimal(1)
Decimal('1')
Tr)rrr~s  r/�copy_decimal�Context.copy_decimal�s��
�1�d�+���q�z�r1c�6�[USS9nUR5$)z�Returns a copy of the operand with the sign inverted.

>>> ExtendedContext.copy_negate(Decimal('101.5'))
Decimal('-101.5')
>>> ExtendedContext.copy_negate(Decimal('-101.5'))
Decimal('101.5')
>>> ExtendedContext.copy_negate(1)
Decimal('-1')
Tr)rrCr~s  r/rC�Context.copy_negate�s��
�1�d�+���}�}��r1c�8�[USS9nURU5$)a�Copies the second operand's sign to the first one.

In detail, it returns a copy of the first operand with the sign
equal to the sign of the second operand.

>>> ExtendedContext.copy_sign(Decimal( '1.50'), Decimal('7.33'))
Decimal('1.50')
>>> ExtendedContext.copy_sign(Decimal('-1.50'), Decimal('7.33'))
Decimal('1.50')
>>> ExtendedContext.copy_sign(Decimal( '1.50'), Decimal('-7.33'))
Decimal('-1.50')
>>> ExtendedContext.copy_sign(Decimal('-1.50'), Decimal('-7.33'))
Decimal('-1.50')
>>> ExtendedContext.copy_sign(1, -2)
Decimal('-1')
>>> ExtendedContext.copy_sign(Decimal(1), -2)
Decimal('-1')
>>> ExtendedContext.copy_sign(1, Decimal(-2))
Decimal('-1')
Tr)rrhr�s   r/rh�Context.copy_sign�s��*
�1�d�+���{�{�1�~�r1c�f�[USS9nURX S9nU[La[SU-5eU$)a�Decimal division in a specified context.

>>> ExtendedContext.divide(Decimal('1'), Decimal('3'))
Decimal('0.333333333')
>>> ExtendedContext.divide(Decimal('2'), Decimal('3'))
Decimal('0.666666667')
>>> ExtendedContext.divide(Decimal('5'), Decimal('2'))
Decimal('2.5')
>>> ExtendedContext.divide(Decimal('1'), Decimal('10'))
Decimal('0.1')
>>> ExtendedContext.divide(Decimal('12'), Decimal('12'))
Decimal('1')
>>> ExtendedContext.divide(Decimal('8.00'), Decimal('2'))
Decimal('4.00')
>>> ExtendedContext.divide(Decimal('2.400'), Decimal('2.0'))
Decimal('1.20')
>>> ExtendedContext.divide(Decimal('1000'), Decimal('100'))
Decimal('10')
>>> ExtendedContext.divide(Decimal('1000'), Decimal('1'))
Decimal('1000')
>>> ExtendedContext.divide(Decimal('2.40E+6'), Decimal('2'))
Decimal('1.20E+6')
>>> ExtendedContext.divide(5, 5)
Decimal('1')
>>> ExtendedContext.divide(Decimal(5), 5)
Decimal('1')
>>> ExtendedContext.divide(5, Decimal(5))
Decimal('1')
Trr�r�)rrjr�r�r�s    r/�divide�Context.divide�s>��<
�1�d�+��
�M�M�!�M�*������=��A�B�B��Hr1c�f�[USS9nURX S9nU[La[SU-5eU$)a�Divides two numbers and returns the integer part of the result.

>>> ExtendedContext.divide_int(Decimal('2'), Decimal('3'))
Decimal('0')
>>> ExtendedContext.divide_int(Decimal('10'), Decimal('3'))
Decimal('3')
>>> ExtendedContext.divide_int(Decimal('1'), Decimal('0.3'))
Decimal('3')
>>> ExtendedContext.divide_int(10, 3)
Decimal('3')
>>> ExtendedContext.divide_int(Decimal(10), 3)
Decimal('3')
>>> ExtendedContext.divide_int(10, Decimal(3))
Decimal('3')
Trr�r�)rr�r�r�r�s    r/�
divide_int�Context.divide_int�s>�� 
�1�d�+��
�N�N�1�N�+������=��A�B�B��Hr1c�f�[USS9nURX S9nU[La[SU-5eU$)a�Return (a // b, a % b).

>>> ExtendedContext.divmod(Decimal(8), Decimal(3))
(Decimal('2'), Decimal('2'))
>>> ExtendedContext.divmod(Decimal(8), Decimal(4))
(Decimal('2'), Decimal('0'))
>>> ExtendedContext.divmod(8, 4)
(Decimal('2'), Decimal('0'))
>>> ExtendedContext.divmod(Decimal(8), 4)
(Decimal('2'), Decimal('0'))
>>> ExtendedContext.divmod(8, Decimal(4))
(Decimal('2'), Decimal('0'))
Trr�r�)rrzr�r�r�s    r/rf�Context.divmod�s>��
�1�d�+��
�L�L��L�)������=��A�B�B��Hr1c�4�[USS9nURUS9$)a�Returns e ** a.

>>> c = ExtendedContext.copy()
>>> c.Emin = -999
>>> c.Emax = 999
>>> c.exp(Decimal('-Infinity'))
Decimal('0')
>>> c.exp(Decimal('-1'))
Decimal('0.367879441')
>>> c.exp(Decimal('0'))
Decimal('1')
>>> c.exp(Decimal('1'))
Decimal('2.71828183')
>>> c.exp(Decimal('0.693147181'))
Decimal('2.00000000')
>>> c.exp(Decimal('+Infinity'))
Decimal('Infinity')
>>> c.exp(10)
Decimal('22026.4658')
Trr�)rr�r~s  r/r��Context.exps!��*�!�T�*���u�u�T�u�"�"r1c�6�[USS9nURX#US9$)a�Returns a multiplied by b, plus c.

The first two operands are multiplied together, using multiply,
the third operand is then added to the result of that
multiplication, using add, all with only one final rounding.

>>> ExtendedContext.fma(Decimal('3'), Decimal('5'), Decimal('7'))
Decimal('22')
>>> ExtendedContext.fma(Decimal('3'), Decimal('-5'), Decimal('7'))
Decimal('-8')
>>> ExtendedContext.fma(Decimal('888565290'), Decimal('1557.96930'), Decimal('-86087.7578'))
Decimal('1.38435736E+12')
>>> ExtendedContext.fma(1, 3, 4)
Decimal('7')
>>> ExtendedContext.fma(1, Decimal(3), 4)
Decimal('7')
>>> ExtendedContext.fma(1, 3, Decimal(4))
Decimal('7')
Trr�)rr�)r7rr�r=s    r/r��Context.fma's#��(
�1�d�+���u�u�Q�4�u�(�(r1c�b�[U[5(d[S5eUR5$)z�Return True if the operand is canonical; otherwise return False.

Currently, the encoding of a Decimal instance is always
canonical, so this method returns True for any Decimal.

>>> ExtendedContext.is_canonical(Decimal('2.50'))
True
z/is_canonical requires a Decimal as an argument.)r�rr�ror~s  r/ro�Context.is_canonical>s*���!�W�%�%��M�N�N��~�~��r1c�6�[USS9nUR5$)a�Return True if the operand is finite; otherwise return False.

A Decimal instance is considered finite if it is neither
infinite nor a NaN.

>>> ExtendedContext.is_finite(Decimal('2.50'))
True
>>> ExtendedContext.is_finite(Decimal('-0.3'))
True
>>> ExtendedContext.is_finite(Decimal('0'))
True
>>> ExtendedContext.is_finite(Decimal('Inf'))
False
>>> ExtendedContext.is_finite(Decimal('NaN'))
False
>>> ExtendedContext.is_finite(1)
True
Tr)rrrr~s  r/rr�Context.is_finiteKs��&
�1�d�+���{�{�}�r1c�6�[USS9nUR5$)a
Return True if the operand is infinite; otherwise return False.

>>> ExtendedContext.is_infinite(Decimal('2.50'))
False
>>> ExtendedContext.is_infinite(Decimal('-Inf'))
True
>>> ExtendedContext.is_infinite(Decimal('NaN'))
False
>>> ExtendedContext.is_infinite(1)
False
Tr)rr)r~s  r/r)�Context.is_infiniteas��
�1�d�+���}�}��r1c�6�[USS9nUR5$)z�Return True if the operand is a qNaN or sNaN;
otherwise return False.

>>> ExtendedContext.is_nan(Decimal('2.50'))
False
>>> ExtendedContext.is_nan(Decimal('NaN'))
True
>>> ExtendedContext.is_nan(Decimal('-sNaN'))
True
>>> ExtendedContext.is_nan(1)
False
Tr)rrr~s  r/r�Context.is_nanps��
�1�d�+���x�x�z�r1c�4�[USS9nURUS9$)agReturn True if the operand is a normal number;
otherwise return False.

>>> c = ExtendedContext.copy()
>>> c.Emin = -999
>>> c.Emax = 999
>>> c.is_normal(Decimal('2.50'))
True
>>> c.is_normal(Decimal('0.1E-999'))
False
>>> c.is_normal(Decimal('0.00'))
False
>>> c.is_normal(Decimal('-Inf'))
False
>>> c.is_normal(Decimal('NaN'))
False
>>> c.is_normal(1)
True
Trr�)rr{r~s  r/r{�Context.is_normal�s!��(
�1�d�+���{�{�4�{�(�(r1c�6�[USS9nUR5$)aReturn True if the operand is a quiet NaN; otherwise return False.

>>> ExtendedContext.is_qnan(Decimal('2.50'))
False
>>> ExtendedContext.is_qnan(Decimal('NaN'))
True
>>> ExtendedContext.is_qnan(Decimal('sNaN'))
False
>>> ExtendedContext.is_qnan(1)
False
Tr)rr�r~s  r/r��Context.is_qnan�s��
�1�d�+���y�y�{�r1c�6�[USS9nUR5$)a)Return True if the operand is negative; otherwise return False.

>>> ExtendedContext.is_signed(Decimal('2.50'))
False
>>> ExtendedContext.is_signed(Decimal('-12'))
True
>>> ExtendedContext.is_signed(Decimal('-0'))
True
>>> ExtendedContext.is_signed(8)
False
>>> ExtendedContext.is_signed(-8)
True
Tr)rr�r~s  r/r��Context.is_signed�s��
�1�d�+���{�{�}�r1c�6�[USS9nUR5$)aReturn True if the operand is a signaling NaN;
otherwise return False.

>>> ExtendedContext.is_snan(Decimal('2.50'))
False
>>> ExtendedContext.is_snan(Decimal('NaN'))
False
>>> ExtendedContext.is_snan(Decimal('sNaN'))
True
>>> ExtendedContext.is_snan(1)
False
Tr)rr�r~s  r/r��Context.is_snan�s��
�1�d�+���y�y�{�r1c�4�[USS9nURUS9$)atReturn True if the operand is subnormal; otherwise return False.

>>> c = ExtendedContext.copy()
>>> c.Emin = -999
>>> c.Emax = 999
>>> c.is_subnormal(Decimal('2.50'))
False
>>> c.is_subnormal(Decimal('0.1E-999'))
True
>>> c.is_subnormal(Decimal('0.00'))
False
>>> c.is_subnormal(Decimal('-Inf'))
False
>>> c.is_subnormal(Decimal('NaN'))
False
>>> c.is_subnormal(1)
False
Trr�)rr�r~s  r/r��Context.is_subnormal�s!��&
�1�d�+���~�~�d�~�+�+r1c�6�[USS9nUR5$)aReturn True if the operand is a zero; otherwise return False.

>>> ExtendedContext.is_zero(Decimal('0'))
True
>>> ExtendedContext.is_zero(Decimal('2.50'))
False
>>> ExtendedContext.is_zero(Decimal('-0E+2'))
True
>>> ExtendedContext.is_zero(1)
False
>>> ExtendedContext.is_zero(0)
True
Tr)rr�r~s  r/r��Context.is_zero�s��
�1�d�+���y�y�{�r1c�4�[USS9nURUS9$)a~Returns the natural (base e) logarithm of the operand.

>>> c = ExtendedContext.copy()
>>> c.Emin = -999
>>> c.Emax = 999
>>> c.ln(Decimal('0'))
Decimal('-Infinity')
>>> c.ln(Decimal('1.000'))
Decimal('0')
>>> c.ln(Decimal('2.71828183'))
Decimal('1.00000000')
>>> c.ln(Decimal('10'))
Decimal('2.30258509')
>>> c.ln(Decimal('+Infinity'))
Decimal('Infinity')
>>> c.ln(1)
Decimal('0')
Trr�)rr�r~s  r/r��
Context.ln�s!��&
�1�d�+���t�t�D�t�!�!r1c�4�[USS9nURUS9$)a�Returns the base 10 logarithm of the operand.

>>> c = ExtendedContext.copy()
>>> c.Emin = -999
>>> c.Emax = 999
>>> c.log10(Decimal('0'))
Decimal('-Infinity')
>>> c.log10(Decimal('0.001'))
Decimal('-3')
>>> c.log10(Decimal('1.000'))
Decimal('0')
>>> c.log10(Decimal('2'))
Decimal('0.301029996')
>>> c.log10(Decimal('10'))
Decimal('1')
>>> c.log10(Decimal('70'))
Decimal('1.84509804')
>>> c.log10(Decimal('+Infinity'))
Decimal('Infinity')
>>> c.log10(0)
Decimal('-Infinity')
>>> c.log10(1)
Decimal('0')
Trr�)rr�r~s  r/r��
Context.log10s!��2
�1�d�+���w�w�t�w�$�$r1c�4�[USS9nURUS9$)a�Returns the exponent of the magnitude of the operand's MSD.

The result is the integer which is the exponent of the magnitude
of the most significant digit of the operand (as though the
operand were truncated to a single digit while maintaining the
value of that digit and without limiting the resulting exponent).

>>> ExtendedContext.logb(Decimal('250'))
Decimal('2')
>>> ExtendedContext.logb(Decimal('2.50'))
Decimal('0')
>>> ExtendedContext.logb(Decimal('0.03'))
Decimal('-2')
>>> ExtendedContext.logb(Decimal('0'))
Decimal('-Infinity')
>>> ExtendedContext.logb(1)
Decimal('0')
>>> ExtendedContext.logb(10)
Decimal('1')
>>> ExtendedContext.logb(100)
Decimal('2')
Trr�)rr�r~s  r/r��Context.logb s!��.
�1�d�+���v�v�d�v�#�#r1c�4�[USS9nURX S9$)a�Applies the logical operation 'and' between each operand's digits.

The operands must be both logical numbers.

>>> ExtendedContext.logical_and(Decimal('0'), Decimal('0'))
Decimal('0')
>>> ExtendedContext.logical_and(Decimal('0'), Decimal('1'))
Decimal('0')
>>> ExtendedContext.logical_and(Decimal('1'), Decimal('0'))
Decimal('0')
>>> ExtendedContext.logical_and(Decimal('1'), Decimal('1'))
Decimal('1')
>>> ExtendedContext.logical_and(Decimal('1100'), Decimal('1010'))
Decimal('1000')
>>> ExtendedContext.logical_and(Decimal('1111'), Decimal('10'))
Decimal('10')
>>> ExtendedContext.logical_and(110, 1101)
Decimal('100')
>>> ExtendedContext.logical_and(Decimal(110), 1101)
Decimal('100')
>>> ExtendedContext.logical_and(110, Decimal(1101))
Decimal('100')
Trr�)rr�r�s   r/r��Context.logical_and:�!��0
�1�d�+���}�}�Q�}�-�-r1c�4�[USS9nURUS9$)a�Invert all the digits in the operand.

The operand must be a logical number.

>>> ExtendedContext.logical_invert(Decimal('0'))
Decimal('111111111')
>>> ExtendedContext.logical_invert(Decimal('1'))
Decimal('111111110')
>>> ExtendedContext.logical_invert(Decimal('111111111'))
Decimal('0')
>>> ExtendedContext.logical_invert(Decimal('101010101'))
Decimal('10101010')
>>> ExtendedContext.logical_invert(1101)
Decimal('111110010')
Trr�)rr�r~s  r/r��Context.logical_invertUs$�� 
�1�d�+�������-�-r1c�4�[USS9nURX S9$)a�Applies the logical operation 'or' between each operand's digits.

The operands must be both logical numbers.

>>> ExtendedContext.logical_or(Decimal('0'), Decimal('0'))
Decimal('0')
>>> ExtendedContext.logical_or(Decimal('0'), Decimal('1'))
Decimal('1')
>>> ExtendedContext.logical_or(Decimal('1'), Decimal('0'))
Decimal('1')
>>> ExtendedContext.logical_or(Decimal('1'), Decimal('1'))
Decimal('1')
>>> ExtendedContext.logical_or(Decimal('1100'), Decimal('1010'))
Decimal('1110')
>>> ExtendedContext.logical_or(Decimal('1110'), Decimal('10'))
Decimal('1110')
>>> ExtendedContext.logical_or(110, 1101)
Decimal('1111')
>>> ExtendedContext.logical_or(Decimal(110), 1101)
Decimal('1111')
>>> ExtendedContext.logical_or(110, Decimal(1101))
Decimal('1111')
Trr�)rr�r�s   r/r��Context.logical_orhs!��0
�1�d�+���|�|�A�|�,�,r1c�4�[USS9nURX S9$)a�Applies the logical operation 'xor' between each operand's digits.

The operands must be both logical numbers.

>>> ExtendedContext.logical_xor(Decimal('0'), Decimal('0'))
Decimal('0')
>>> ExtendedContext.logical_xor(Decimal('0'), Decimal('1'))
Decimal('1')
>>> ExtendedContext.logical_xor(Decimal('1'), Decimal('0'))
Decimal('1')
>>> ExtendedContext.logical_xor(Decimal('1'), Decimal('1'))
Decimal('0')
>>> ExtendedContext.logical_xor(Decimal('1100'), Decimal('1010'))
Decimal('110')
>>> ExtendedContext.logical_xor(Decimal('1111'), Decimal('10'))
Decimal('1101')
>>> ExtendedContext.logical_xor(110, 1101)
Decimal('1011')
>>> ExtendedContext.logical_xor(Decimal(110), 1101)
Decimal('1011')
>>> ExtendedContext.logical_xor(110, Decimal(1101))
Decimal('1011')
Trr�)rr�r�s   r/r��Context.logical_xor�r�r1c�4�[USS9nURX S9$)amax compares two values numerically and returns the maximum.

If either operand is a NaN then the general rules apply.
Otherwise, the operands are compared as though by the compare
operation.  If they are numerically equal then the left-hand operand
is chosen as the result.  Otherwise the maximum (closer to positive
infinity) of the two operands is chosen as the result.

>>> ExtendedContext.max(Decimal('3'), Decimal('2'))
Decimal('3')
>>> ExtendedContext.max(Decimal('-10'), Decimal('3'))
Decimal('3')
>>> ExtendedContext.max(Decimal('1.0'), Decimal('1'))
Decimal('1')
>>> ExtendedContext.max(Decimal('7'), Decimal('NaN'))
Decimal('7')
>>> ExtendedContext.max(1, 2)
Decimal('2')
>>> ExtendedContext.max(Decimal(1), 2)
Decimal('2')
>>> ExtendedContext.max(1, Decimal(2))
Decimal('2')
Trr�)rrPr�s   r/rP�Context.max��!��0
�1�d�+���u�u�Q�u�%�%r1c�4�[USS9nURX S9$)aoCompares the values numerically with their sign ignored.

>>> ExtendedContext.max_mag(Decimal('7'), Decimal('NaN'))
Decimal('7')
>>> ExtendedContext.max_mag(Decimal('7'), Decimal('-10'))
Decimal('-10')
>>> ExtendedContext.max_mag(1, -2)
Decimal('-2')
>>> ExtendedContext.max_mag(Decimal(1), -2)
Decimal('-2')
>>> ExtendedContext.max_mag(1, Decimal(-2))
Decimal('-2')
Trr�)rr�r�s   r/r��Context.max_mag��!��
�1�d�+���y�y��y�)�)r1c�4�[USS9nURX S9$)amin compares two values numerically and returns the minimum.

If either operand is a NaN then the general rules apply.
Otherwise, the operands are compared as though by the compare
operation.  If they are numerically equal then the left-hand operand
is chosen as the result.  Otherwise the minimum (closer to negative
infinity) of the two operands is chosen as the result.

>>> ExtendedContext.min(Decimal('3'), Decimal('2'))
Decimal('2')
>>> ExtendedContext.min(Decimal('-10'), Decimal('3'))
Decimal('-10')
>>> ExtendedContext.min(Decimal('1.0'), Decimal('1'))
Decimal('1.0')
>>> ExtendedContext.min(Decimal('7'), Decimal('NaN'))
Decimal('7')
>>> ExtendedContext.min(1, 2)
Decimal('1')
>>> ExtendedContext.min(Decimal(1), 2)
Decimal('1')
>>> ExtendedContext.min(1, Decimal(29))
Decimal('1')
Trr�)rr)r�s   r/r)�Context.min�r�r1c�4�[USS9nURX S9$)alCompares the values numerically with their sign ignored.

>>> ExtendedContext.min_mag(Decimal('3'), Decimal('-2'))
Decimal('-2')
>>> ExtendedContext.min_mag(Decimal('-3'), Decimal('NaN'))
Decimal('-3')
>>> ExtendedContext.min_mag(1, -2)
Decimal('1')
>>> ExtendedContext.min_mag(Decimal(1), -2)
Decimal('1')
>>> ExtendedContext.min_mag(1, Decimal(-2))
Decimal('1')
Trr�)rr�r�s   r/r��Context.min_mag�r�r1c�4�[USS9nURUS9$)a~Minus corresponds to unary prefix minus in Python.

The operation is evaluated using the same rules as subtract; the
operation minus(a) is calculated as subtract('0', a) where the '0'
has the same exponent as the operand.

>>> ExtendedContext.minus(Decimal('1.3'))
Decimal('-1.3')
>>> ExtendedContext.minus(Decimal('-1.3'))
Decimal('1.3')
>>> ExtendedContext.minus(1)
Decimal('-1')
Trr�)rrFr~s  r/�minus�
Context.minus��!��
�1�d�+���y�y��y�&�&r1c�f�[USS9nURX S9nU[La[SU-5eU$)a8multiply multiplies two operands.

If either operand is a special value then the general rules apply.
Otherwise, the operands are multiplied together
('long multiplication'), resulting in a number which may be as long as
the sum of the lengths of the two operands.

>>> ExtendedContext.multiply(Decimal('1.20'), Decimal('3'))
Decimal('3.60')
>>> ExtendedContext.multiply(Decimal('7'), Decimal('3'))
Decimal('21')
>>> ExtendedContext.multiply(Decimal('0.9'), Decimal('0.8'))
Decimal('0.72')
>>> ExtendedContext.multiply(Decimal('0.9'), Decimal('-0'))
Decimal('-0.0')
>>> ExtendedContext.multiply(Decimal('654321'), Decimal('654321'))
Decimal('4.28135971E+11')
>>> ExtendedContext.multiply(7, 7)
Decimal('49')
>>> ExtendedContext.multiply(Decimal(7), 7)
Decimal('49')
>>> ExtendedContext.multiply(7, Decimal(7))
Decimal('49')
Trr�r�)rrbr�r�r�s    r/�multiply�Context.multiplys>��2
�1�d�+��
�I�I�a�I�&������=��A�B�B��Hr1c�4�[USS9nURUS9$)a�Returns the largest representable number smaller than a.

>>> c = ExtendedContext.copy()
>>> c.Emin = -999
>>> c.Emax = 999
>>> ExtendedContext.next_minus(Decimal('1'))
Decimal('0.999999999')
>>> c.next_minus(Decimal('1E-1007'))
Decimal('0E-1007')
>>> ExtendedContext.next_minus(Decimal('-1.00000003'))
Decimal('-1.00000004')
>>> c.next_minus(Decimal('Infinity'))
Decimal('9.99999999E+999')
>>> c.next_minus(1)
Decimal('0.999999999')
Trr�)rr�r~s  r/r��Context.next_minus's!��"
�1�d�+���|�|�D�|�)�)r1c�4�[USS9nURUS9$)a�Returns the smallest representable number larger than a.

>>> c = ExtendedContext.copy()
>>> c.Emin = -999
>>> c.Emax = 999
>>> ExtendedContext.next_plus(Decimal('1'))
Decimal('1.00000001')
>>> c.next_plus(Decimal('-1E-1007'))
Decimal('-0E-1007')
>>> ExtendedContext.next_plus(Decimal('-1.00000003'))
Decimal('-1.00000002')
>>> c.next_plus(Decimal('-Infinity'))
Decimal('-9.99999999E+999')
>>> c.next_plus(1)
Decimal('1.00000001')
Trr�)rr�r~s  r/r��Context.next_plus;s!��"
�1�d�+���{�{�4�{�(�(r1c�4�[USS9nURX S9$)a�Returns the number closest to a, in direction towards b.

The result is the closest representable number from the first
operand (but not the first operand) that is in the direction
towards the second operand, unless the operands have the same
value.

>>> c = ExtendedContext.copy()
>>> c.Emin = -999
>>> c.Emax = 999
>>> c.next_toward(Decimal('1'), Decimal('2'))
Decimal('1.00000001')
>>> c.next_toward(Decimal('-1E-1007'), Decimal('1'))
Decimal('-0E-1007')
>>> c.next_toward(Decimal('-1.00000003'), Decimal('0'))
Decimal('-1.00000002')
>>> c.next_toward(Decimal('1'), Decimal('0'))
Decimal('0.999999999')
>>> c.next_toward(Decimal('1E-1007'), Decimal('-100'))
Decimal('0E-1007')
>>> c.next_toward(Decimal('-1.00000003'), Decimal('-10'))
Decimal('-1.00000004')
>>> c.next_toward(Decimal('0.00'), Decimal('-0.0000'))
Decimal('-0.00')
>>> c.next_toward(0, 1)
Decimal('1E-1007')
>>> c.next_toward(Decimal(0), 1)
Decimal('1E-1007')
>>> c.next_toward(0, Decimal(1))
Decimal('1E-1007')
Trr�)rr�r�s   r/r��Context.next_towardOs"��@
�1�d�+���}�}�Q�}�-�-r1c�4�[USS9nURUS9$)a+normalize reduces an operand to its simplest form.

Essentially a plus operation with all trailing zeros removed from the
result.

>>> ExtendedContext.normalize(Decimal('2.1'))
Decimal('2.1')
>>> ExtendedContext.normalize(Decimal('-2.0'))
Decimal('-2')
>>> ExtendedContext.normalize(Decimal('1.200'))
Decimal('1.2')
>>> ExtendedContext.normalize(Decimal('-120'))
Decimal('-1.2E+2')
>>> ExtendedContext.normalize(Decimal('120.00'))
Decimal('1.2E+2')
>>> ExtendedContext.normalize(Decimal('0.00'))
Decimal('0')
>>> ExtendedContext.normalize(6)
Decimal('6')
Trr�)rr$r~s  r/r$�Context.normalizers!��*
�1�d�+���{�{�4�{�(�(r1c�4�[USS9nURUS9$)a�Returns an indication of the class of the operand.

The class is one of the following strings:
  -sNaN
  -NaN
  -Infinity
  -Normal
  -Subnormal
  -Zero
  +Zero
  +Subnormal
  +Normal
  +Infinity

>>> c = ExtendedContext.copy()
>>> c.Emin = -999
>>> c.Emax = 999
>>> c.number_class(Decimal('Infinity'))
'+Infinity'
>>> c.number_class(Decimal('1E-10'))
'+Normal'
>>> c.number_class(Decimal('2.50'))
'+Normal'
>>> c.number_class(Decimal('0.1E-999'))
'+Subnormal'
>>> c.number_class(Decimal('0'))
'+Zero'
>>> c.number_class(Decimal('-0'))
'-Zero'
>>> c.number_class(Decimal('-0.1E-999'))
'-Subnormal'
>>> c.number_class(Decimal('-1E-10'))
'-Normal'
>>> c.number_class(Decimal('-2.50'))
'-Normal'
>>> c.number_class(Decimal('-Infinity'))
'-Infinity'
>>> c.number_class(Decimal('NaN'))
'NaN'
>>> c.number_class(Decimal('-NaN'))
'NaN'
>>> c.number_class(Decimal('sNaN'))
'sNaN'
>>> c.number_class(123)
'+Normal'
Trr�)rr�r~s  r/r��Context.number_class�s"��^
�1�d�+���~�~�d�~�+�+r1c�4�[USS9nURUS9$)aoPlus corresponds to unary prefix plus in Python.

The operation is evaluated using the same rules as add; the
operation plus(a) is calculated as add('0', a) where the '0'
has the same exponent as the operand.

>>> ExtendedContext.plus(Decimal('1.3'))
Decimal('1.3')
>>> ExtendedContext.plus(Decimal('-1.3'))
Decimal('-1.3')
>>> ExtendedContext.plus(-1)
Decimal('-1')
Trr�)rrIr~s  r/�plus�Context.plus�r�r1c�h�[USS9nURX#US9nU[La[SU-5eU$)a�Raises a to the power of b, to modulo if given.

With two arguments, compute a**b.  If a is negative then b
must be integral.  The result will be inexact unless b is
integral and the result is finite and can be expressed exactly
in 'precision' digits.

With three arguments, compute (a**b) % modulo.  For the
three argument form, the following restrictions on the
arguments hold:

 - all three arguments must be integral
 - b must be nonnegative
 - at least one of a or b must be nonzero
 - modulo must be nonzero and have at most 'precision' digits

The result of pow(a, b, modulo) is identical to the result
that would be obtained by computing (a**b) % modulo with
unbounded precision, but is computed more efficiently.  It is
always exact.

>>> c = ExtendedContext.copy()
>>> c.Emin = -999
>>> c.Emax = 999
>>> c.power(Decimal('2'), Decimal('3'))
Decimal('8')
>>> c.power(Decimal('-2'), Decimal('3'))
Decimal('-8')
>>> c.power(Decimal('2'), Decimal('-3'))
Decimal('0.125')
>>> c.power(Decimal('1.7'), Decimal('8'))
Decimal('69.7575744')
>>> c.power(Decimal('10'), Decimal('0.301029996'))
Decimal('2.00000000')
>>> c.power(Decimal('Infinity'), Decimal('-1'))
Decimal('0')
>>> c.power(Decimal('Infinity'), Decimal('0'))
Decimal('1')
>>> c.power(Decimal('Infinity'), Decimal('1'))
Decimal('Infinity')
>>> c.power(Decimal('-Infinity'), Decimal('-1'))
Decimal('-0')
>>> c.power(Decimal('-Infinity'), Decimal('0'))
Decimal('1')
>>> c.power(Decimal('-Infinity'), Decimal('1'))
Decimal('-Infinity')
>>> c.power(Decimal('-Infinity'), Decimal('2'))
Decimal('Infinity')
>>> c.power(Decimal('0'), Decimal('0'))
Decimal('NaN')

>>> c.power(Decimal('3'), Decimal('7'), Decimal('16'))
Decimal('11')
>>> c.power(Decimal('-3'), Decimal('7'), Decimal('16'))
Decimal('-11')
>>> c.power(Decimal('-3'), Decimal('8'), Decimal('16'))
Decimal('1')
>>> c.power(Decimal('3'), Decimal('7'), Decimal('-16'))
Decimal('11')
>>> c.power(Decimal('23E12345'), Decimal('67E189'), Decimal('123456789'))
Decimal('11729830')
>>> c.power(Decimal('-0'), Decimal('17'), Decimal('1729'))
Decimal('-0')
>>> c.power(Decimal('-23'), Decimal('0'), Decimal('65537'))
Decimal('1')
>>> ExtendedContext.power(7, 7)
Decimal('823543')
>>> ExtendedContext.power(Decimal(7), 7)
Decimal('823543')
>>> ExtendedContext.power(7, Decimal(7), 2)
Decimal('1')
Trr�r�)rrr�r�)r7rr�r�ros     r/�power�
Context.power�sA��R
�1�d�+��
�I�I�a��I�.������=��A�B�B��Hr1c�4�[USS9nURX S9$)a�Returns a value equal to 'a' (rounded), having the exponent of 'b'.

The coefficient of the result is derived from that of the left-hand
operand.  It may be rounded using the current rounding setting (if the
exponent is being increased), multiplied by a positive power of ten (if
the exponent is being decreased), or is unchanged (if the exponent is
already equal to that of the right-hand operand).

Unlike other operations, if the length of the coefficient after the
quantize operation would be greater than precision then an Invalid
operation condition is raised.  This guarantees that, unless there is
an error condition, the exponent of the result of a quantize is always
equal to that of the right-hand operand.

Also unlike other operations, quantize will never raise Underflow, even
if the result is subnormal and inexact.

>>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.001'))
Decimal('2.170')
>>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.01'))
Decimal('2.17')
>>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.1'))
Decimal('2.2')
>>> ExtendedContext.quantize(Decimal('2.17'), Decimal('1e+0'))
Decimal('2')
>>> ExtendedContext.quantize(Decimal('2.17'), Decimal('1e+1'))
Decimal('0E+1')
>>> ExtendedContext.quantize(Decimal('-Inf'), Decimal('Infinity'))
Decimal('-Infinity')
>>> ExtendedContext.quantize(Decimal('2'), Decimal('Infinity'))
Decimal('NaN')
>>> ExtendedContext.quantize(Decimal('-0.1'), Decimal('1'))
Decimal('-0')
>>> ExtendedContext.quantize(Decimal('-0'), Decimal('1e+5'))
Decimal('-0E+5')
>>> ExtendedContext.quantize(Decimal('+35236450.6'), Decimal('1e-2'))
Decimal('NaN')
>>> ExtendedContext.quantize(Decimal('-35236450.6'), Decimal('1e-2'))
Decimal('NaN')
>>> ExtendedContext.quantize(Decimal('217'), Decimal('1e-1'))
Decimal('217.0')
>>> ExtendedContext.quantize(Decimal('217'), Decimal('1e-0'))
Decimal('217')
>>> ExtendedContext.quantize(Decimal('217'), Decimal('1e+1'))
Decimal('2.2E+2')
>>> ExtendedContext.quantize(Decimal('217'), Decimal('1e+2'))
Decimal('2E+2')
>>> ExtendedContext.quantize(1, 2)
Decimal('1')
>>> ExtendedContext.quantize(Decimal(1), 2)
Decimal('1')
>>> ExtendedContext.quantize(1, Decimal(2))
Decimal('1')
Trr�)rr�r�s   r/r��Context.quantizes"��n
�1�d�+���z�z�!�z�*�*r1c��[S5$)zSJust returns 10, as this is Decimal, :)

>>> ExtendedContext.radix()
Decimal('10')
rr�r�s r/r��
Context.radixWs���r�{�r1c�f�[USS9nURX S9nU[La[SU-5eU$)aFReturns the remainder from integer division.

The result is the residue of the dividend after the operation of
calculating integer division as described for divide-integer, rounded
to precision digits if necessary.  The sign of the result, if
non-zero, is the same as that of the original dividend.

This operation will fail under the same conditions as integer division
(that is, if integer division on the same two operands would fail, the
remainder cannot be calculated).

>>> ExtendedContext.remainder(Decimal('2.1'), Decimal('3'))
Decimal('2.1')
>>> ExtendedContext.remainder(Decimal('10'), Decimal('3'))
Decimal('1')
>>> ExtendedContext.remainder(Decimal('-10'), Decimal('3'))
Decimal('-1')
>>> ExtendedContext.remainder(Decimal('10.2'), Decimal('1'))
Decimal('0.2')
>>> ExtendedContext.remainder(Decimal('10'), Decimal('0.3'))
Decimal('0.1')
>>> ExtendedContext.remainder(Decimal('3.6'), Decimal('1.3'))
Decimal('1.0')
>>> ExtendedContext.remainder(22, 6)
Decimal('4')
>>> ExtendedContext.remainder(Decimal(22), 6)
Decimal('4')
>>> ExtendedContext.remainder(22, Decimal(6))
Decimal('4')
Trr�r�)rr�r�r�r�s    r/rh�Context.remainder_s>��>
�1�d�+��
�I�I�a�I�&������=��A�B�B��Hr1c�4�[USS9nURX S9$)aoReturns to be "a - b * n", where n is the integer nearest the exact
value of "x / b" (if two integers are equally near then the even one
is chosen).  If the result is equal to 0 then its sign will be the
sign of a.

This operation will fail under the same conditions as integer division
(that is, if integer division on the same two operands would fail, the
remainder cannot be calculated).

>>> ExtendedContext.remainder_near(Decimal('2.1'), Decimal('3'))
Decimal('-0.9')
>>> ExtendedContext.remainder_near(Decimal('10'), Decimal('6'))
Decimal('-2')
>>> ExtendedContext.remainder_near(Decimal('10'), Decimal('3'))
Decimal('1')
>>> ExtendedContext.remainder_near(Decimal('-10'), Decimal('3'))
Decimal('-1')
>>> ExtendedContext.remainder_near(Decimal('10.2'), Decimal('1'))
Decimal('0.2')
>>> ExtendedContext.remainder_near(Decimal('10'), Decimal('0.3'))
Decimal('0.1')
>>> ExtendedContext.remainder_near(Decimal('3.6'), Decimal('1.3'))
Decimal('-0.3')
>>> ExtendedContext.remainder_near(3, 11)
Decimal('3')
>>> ExtendedContext.remainder_near(Decimal(3), 11)
Decimal('3')
>>> ExtendedContext.remainder_near(3, Decimal(11))
Decimal('3')
Trr�)rr�r�s   r/r��Context.remainder_near�s$��>
�1�d�+�������0�0r1c�4�[USS9nURX S9$)a�Returns a rotated copy of a, b times.

The coefficient of the result is a rotated copy of the digits in
the coefficient of the first operand.  The number of places of
rotation is taken from the absolute value of the second operand,
with the rotation being to the left if the second operand is
positive or to the right otherwise.

>>> ExtendedContext.rotate(Decimal('34'), Decimal('8'))
Decimal('400000003')
>>> ExtendedContext.rotate(Decimal('12'), Decimal('9'))
Decimal('12')
>>> ExtendedContext.rotate(Decimal('123456789'), Decimal('-2'))
Decimal('891234567')
>>> ExtendedContext.rotate(Decimal('123456789'), Decimal('0'))
Decimal('123456789')
>>> ExtendedContext.rotate(Decimal('123456789'), Decimal('+2'))
Decimal('345678912')
>>> ExtendedContext.rotate(1333333, 1)
Decimal('13333330')
>>> ExtendedContext.rotate(Decimal(1333333), 1)
Decimal('13333330')
>>> ExtendedContext.rotate(1333333, Decimal(1))
Decimal('13333330')
Trr�)rr�r�s   r/r��Context.rotate�s!��4
�1�d�+���x�x��x�(�(r1c�8�[USS9nURU5$)aUReturns True if the two operands have the same exponent.

The result is never affected by either the sign or the coefficient of
either operand.

>>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('0.001'))
False
>>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('0.01'))
True
>>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('1'))
False
>>> ExtendedContext.same_quantum(Decimal('Inf'), Decimal('-Inf'))
True
>>> ExtendedContext.same_quantum(10000, -1)
True
>>> ExtendedContext.same_quantum(Decimal(10000), -1)
True
>>> ExtendedContext.same_quantum(10000, Decimal(-1))
True
Tr)rr*r�s   r/r*�Context.same_quantum�s��*
�1�d�+���~�~�a� � r1c�4�[USS9nURX S9$)a�Returns the first operand after adding the second value its exp.

>>> ExtendedContext.scaleb(Decimal('7.50'), Decimal('-2'))
Decimal('0.0750')
>>> ExtendedContext.scaleb(Decimal('7.50'), Decimal('0'))
Decimal('7.50')
>>> ExtendedContext.scaleb(Decimal('7.50'), Decimal('3'))
Decimal('7.50E+3')
>>> ExtendedContext.scaleb(1, 4)
Decimal('1E+4')
>>> ExtendedContext.scaleb(Decimal(1), 4)
Decimal('1E+4')
>>> ExtendedContext.scaleb(1, Decimal(4))
Decimal('1E+4')
Trr�)rr�r�s   r/r��Context.scaleb�s!�� 
�1�d�+���x�x��x�(�(r1c�4�[USS9nURX S9$)a�Returns a shifted copy of a, b times.

The coefficient of the result is a shifted copy of the digits
in the coefficient of the first operand.  The number of places
to shift is taken from the absolute value of the second operand,
with the shift being to the left if the second operand is
positive or to the right otherwise.  Digits shifted into the
coefficient are zeros.

>>> ExtendedContext.shift(Decimal('34'), Decimal('8'))
Decimal('400000000')
>>> ExtendedContext.shift(Decimal('12'), Decimal('9'))
Decimal('0')
>>> ExtendedContext.shift(Decimal('123456789'), Decimal('-2'))
Decimal('1234567')
>>> ExtendedContext.shift(Decimal('123456789'), Decimal('0'))
Decimal('123456789')
>>> ExtendedContext.shift(Decimal('123456789'), Decimal('+2'))
Decimal('345678900')
>>> ExtendedContext.shift(88888888, 2)
Decimal('888888800')
>>> ExtendedContext.shift(Decimal(88888888), 2)
Decimal('888888800')
>>> ExtendedContext.shift(88888888, Decimal(2))
Decimal('888888800')
Trr�)rrgr�s   r/rg�
Context.shift�s!��6
�1�d�+���w�w�q�w�'�'r1c�4�[USS9nURUS9$)a�Square root of a non-negative number to context precision.

If the result must be inexact, it is rounded using the round-half-even
algorithm.

>>> ExtendedContext.sqrt(Decimal('0'))
Decimal('0')
>>> ExtendedContext.sqrt(Decimal('-0'))
Decimal('-0')
>>> ExtendedContext.sqrt(Decimal('0.39'))
Decimal('0.624499800')
>>> ExtendedContext.sqrt(Decimal('100'))
Decimal('10')
>>> ExtendedContext.sqrt(Decimal('1'))
Decimal('1')
>>> ExtendedContext.sqrt(Decimal('1.0'))
Decimal('1.0')
>>> ExtendedContext.sqrt(Decimal('1.00'))
Decimal('1.0')
>>> ExtendedContext.sqrt(Decimal('7'))
Decimal('2.64575131')
>>> ExtendedContext.sqrt(Decimal('10'))
Decimal('3.16227766')
>>> ExtendedContext.sqrt(2)
Decimal('1.41421356')
>>> ExtendedContext.prec
9
Trr�)rr?r~s  r/r?�Context.sqrt
s!��:
�1�d�+���v�v�d�v�#�#r1c�f�[USS9nURX S9nU[La[SU-5eU$)a�Return the difference between the two operands.

>>> ExtendedContext.subtract(Decimal('1.3'), Decimal('1.07'))
Decimal('0.23')
>>> ExtendedContext.subtract(Decimal('1.3'), Decimal('1.30'))
Decimal('0.00')
>>> ExtendedContext.subtract(Decimal('1.3'), Decimal('2.07'))
Decimal('-0.77')
>>> ExtendedContext.subtract(8, 5)
Decimal('3')
>>> ExtendedContext.subtract(Decimal(8), 5)
Decimal('3')
>>> ExtendedContext.subtract(8, Decimal(5))
Decimal('3')
Trr�r�)rrYr�r�r�s    r/�subtract�Context.subtract-s>�� 
�1�d�+��
�I�I�a�I�&������=��A�B�B��Hr1c�4�[USS9nURUS9$)a�Convert to a string, using engineering notation if an exponent is needed.

Engineering notation has an exponent which is a multiple of 3.  This
can leave up to 3 digits to the left of the decimal place and may
require the addition of either one or two trailing zeros.

The operation is not affected by the context.

>>> ExtendedContext.to_eng_string(Decimal('123E+1'))
'1.23E+3'
>>> ExtendedContext.to_eng_string(Decimal('123E+3'))
'123E+3'
>>> ExtendedContext.to_eng_string(Decimal('123E-10'))
'12.3E-9'
>>> ExtendedContext.to_eng_string(Decimal('-123E-12'))
'-123E-12'
>>> ExtendedContext.to_eng_string(Decimal('7E-7'))
'700E-9'
>>> ExtendedContext.to_eng_string(Decimal('7E+1'))
'70'
>>> ExtendedContext.to_eng_string(Decimal('0E+1'))
'0.00E+3'

Trr�)rr?r~s  r/r?�Context.to_eng_stringDs!��2
�1�d�+�����t��,�,r1c�4�[USS9nURUS9$)ziConverts a number to a string, using scientific notation.

The operation is not affected by the context.
Trr�)rr;r~s  r/�
to_sci_string�Context.to_sci_string`s!��

�1�d�+���y�y��y�&�&r1c�4�[USS9nURUS9$)a�Rounds to an integer.

When the operand has a negative exponent, the result is the same
as using the quantize() operation using the given operand as the
left-hand-operand, 1E+0 as the right-hand-operand, and the precision
of the operand as the precision setting; Inexact and Rounded flags
are allowed in this operation.  The rounding mode is taken from the
context.

>>> ExtendedContext.to_integral_exact(Decimal('2.1'))
Decimal('2')
>>> ExtendedContext.to_integral_exact(Decimal('100'))
Decimal('100')
>>> ExtendedContext.to_integral_exact(Decimal('100.0'))
Decimal('100')
>>> ExtendedContext.to_integral_exact(Decimal('101.5'))
Decimal('102')
>>> ExtendedContext.to_integral_exact(Decimal('-101.5'))
Decimal('-102')
>>> ExtendedContext.to_integral_exact(Decimal('10E+5'))
Decimal('1.0E+6')
>>> ExtendedContext.to_integral_exact(Decimal('7.89E+77'))
Decimal('7.89E+77')
>>> ExtendedContext.to_integral_exact(Decimal('-Inf'))
Decimal('-Infinity')
Trr�)rr5r~s  r/r5�Context.to_integral_exacths$��6
�1�d�+���"�"�4�"�0�0r1c�4�[USS9nURUS9$)a�Rounds to an integer.

When the operand has a negative exponent, the result is the same
as using the quantize() operation using the given operand as the
left-hand-operand, 1E+0 as the right-hand-operand, and the precision
of the operand as the precision setting, except that no flags will
be set.  The rounding mode is taken from the context.

>>> ExtendedContext.to_integral_value(Decimal('2.1'))
Decimal('2')
>>> ExtendedContext.to_integral_value(Decimal('100'))
Decimal('100')
>>> ExtendedContext.to_integral_value(Decimal('100.0'))
Decimal('100')
>>> ExtendedContext.to_integral_value(Decimal('101.5'))
Decimal('102')
>>> ExtendedContext.to_integral_value(Decimal('-101.5'))
Decimal('-102')
>>> ExtendedContext.to_integral_value(Decimal('10E+5'))
Decimal('1.0E+6')
>>> ExtendedContext.to_integral_value(Decimal('7.89E+77'))
Decimal('7.89E+77')
>>> ExtendedContext.to_integral_value(Decimal('-Inf'))
Decimal('-Infinity')
Trr�)rr�r~s  r/r��Context.to_integral_value�s$��4
�1�d�+���"�"�4�"�0�0r1)	rwr}r2r~rr�rvrur�)	NNNNNNNNNr,)r�)Zr<r=r>r?r@rr<r@r8rGr�r/r�rYr:r�r�r�r�rhrnrrer�r;rxr{r�r�r�rRrrUrCrarBr�rCrhr�r�rfr�r�rorrr)rr{r�r�r�r�r�r�r�r�r�r�r�r�rPr�r)r�r�r�r�r�r�r$r�r�r�r�r�rhr�r�r*r�rgr?r�r?rr5r�rrAr-r1r/rr�s����$BF�DH�&*�"�H5�	1�I�2<�;�"�!�
!�
���H�!�,-��-��H�.�.��&�"�$'�*�*!��"*�H!1�F"�:&�����0#�J�.�*#�0)�. ��,
�� )�.
��"� ,�,�""�,%�8$�4.�6.�&-�6.�6&�6*�"&�6*�"'�"�@*�()�(!.�F)�00,�d'�"N�`8+�t�$�L 1�D)�:!�0)�&(�<$�@�.-�8'�1�<1�<$�Kr1rc�(�\rSrSrSrSSjrSrSrg)r�i��r\r�r�Nc��UcSUlSUlSUlg[U[5(a=UR
Ul[UR5UlURUlgUSUlUSUlUSUlg)Nr(r2r�)r\r�r�r�rrKrLr�)r7r�s  r/r�_WorkRep.__init__�sq���=��D�I��D�H��D�H�
��w�
'�
'����D�I��5�:�:��D�H��z�z�D�H��a��D�I��Q�x�D�H��Q�x�D�Hr1c�\�SUR<SUR<SUR<S3$)N�(rMrOrr�s r/r/�_WorkRep.__repr__�s��!%���D�H�H�d�h�h�?�?r1)r�r�r\r,)r<r=r>r?rrr/rAr-r1r/r�r��s��$�I�

 �@r1r�c���URUR:aUnUnOUnUn[[UR55n[[UR55nUR[	SXR-
S-
5-nXdR-S-
U:a
SUlXtlU=RSURUR-
--slURUlX4$)z[Normalizes op1, op2 to have the same exp and length of coefficient.

Done during addition.
r�r�r2r)r�r�r�r�r))rTrUrv�tmpr��tmp_len�	other_lenr�s        r/rRrR�s���
�w�w��������������#�c�g�g�,��G��C��	�	�N�#�I�

�'�'�C��G�N�Q�.�/�
/�C��9�9��q� �3�&���	��	��G�G�r�c�g�g��	�	�)�*�*�G��i�i�C�G��8�Or1c���US:XagUS:�aUSU--$[[U55n[U5[URS55-
nX1*:aS$USU*--$)z�Given integers n and e, return n * 10**e if it's an integer, else None.

The computation is designed to avoid computing large powers of 10
unnecessarily.

>>> _decimal_lshift_exact(3, 4)
30000
>>> _decimal_lshift_exact(300, -999999999)  # returns None

r(rr�N)r�r�r��rstrip)rIr6�str_n�val_ns    r/r�r��si��	�A�v��	
�a���2�q�5�y���C��F����E�
�S����c�!2�3�3���r�z�t�2�q�B���F�{�2r1c�h�US::dUS::a[S5eSnX:waXU*U--
S-	pX:waMU$)z�Closest integer to the square root of the positive integer n.  a is
an initial approximation to the square root.  Any positive integer
will do for a, but the closer a is to the square root of n the
faster convergence will be.

r(z3Both arguments to _sqrt_nearest should be positive.r2)r�)rIrr�s   r/�
_sqrt_nearestr�sF��	�A�v��a���N�O�O��A�
�&��Q�B��E�'�1�*�1��&��Hr1c�>�SU-X-	p2USXS-
--US--U:�-$)z�Given an integer x and a nonnegative integer shift, return closest
integer to x / 2**shift; use round-to-even in case of a tie.

r2r�r-)r�rgr�rns    r/�_rshift_nearestrs4��

��:�q�z�q���1�!��9�
��1��%��)�*�*r1c�>�[X5up#USU-US--U:�-$)zYClosest integer to a/b, a and b positive integers; rounds to even
in the case of a tie.

r�r2)rf)rr�rnros    r/�_div_nearestrs*��
�!�<�D�A���!��q��s��a�� � r1c�8�X-
nSnXB::a[U5X$-
-U:�dXB:�a{[U5XB-
-	U:�ag[X-S-U[X[X45--U5-5nUS-
nXB::a[U5X$-
-U:�aMLXB:�a[U5XB-
-	U:�aMg[	S[[
U55-SU--5*n[X45n[X5n[US-
SS5Hn[X5[Xg-U5-
nM [Xs-U5$)a�Integer approximation to M*log(x/M), with absolute error boundable
in terms only of x/M.

Given positive integers x and M, return an integer approximation to
M * log(x/M).  For L = 8 and 0.1 <= x/M <= 10 the difference
between the approximation and the exact result is at most 22.  For
L = 8 and 1.0 <= x/M <= 10.0 the difference is at most 15.  In
both cases these are upper bounds on the error; it will usually be
much smaller.r(r2���r�r�)r�rrrr�r�r�r�)	r��M�Lr�R�T�yshift�wr�s	         r/�_ilogr's��<	
��A�	�A��6�c�!�f���m�q�(��5�S��V�q�s�]�a�'��!�#�!���]�1���0E�.E�+F��J�J�
L��	�Q���	
�6�c�!�f���m�q�(��5�S��V�q�s�]�a�'�

�S��S��V��_�q��s�
#�	$�$�A�
�Q�
"�F��Q��A�
�1�Q�3��2�
������f�h��!:�:������Q��r1c�@�US-
n[[U55nX-X-S:�-
nUS:�aTSU-nX-U-
nUS:�a	USU--nO[USU*-5n[X5n[	U5n[Xu-U5nXE-n	OSn[USU*-5n	[X�-S5$)z�Given integers c, e and p with c > 0, p >= 0, compute an integer
approximation to 10**p * log10(c*10**e), with an absolute error of
at most 1.  Assumes that c*10**e is not exactly 1.r�r2r(rr�)r�r�rr'�
_log10_digits)
r=r6r�r>r�r!r��log_d�log_10�log_tenpowers
          r/r�r�Ds�����F�A�	�C��F��A�	��q�s�a�x��A��1�u���E��
�C��E����6�
��Q��J�A��Q��Q�B��'�A��a����q�!���U�W�f�-���s����#�A�r�A�2�v�.����*�C�0�0r1c��US-
n[[U55nX-X-S:�-
nUS:�a6X-U-
nUS:�a	USU--nO[USU*-5n[USU-5nOSnU(aI[[[	U555S-
nX'-S:�a[U[X'-5-SU-5nOSnOSn[X�-S5$)z�Given integers c, e and p with c > 0, compute an integer
approximation to 10**p * log(c*10**e), with an absolute error of
at most 1.  Assumes that c*10**e is not exactly 1.r�r2r(rr�)r�r�rr'r�r))	r=r6r�r>r�r�r*r�	f_log_tens	         r/r�r�fs�����F�A�
	�C��F��A�	��q�s�a�x��A�	�1�u�
�C��E����6�
��Q��J�A��Q��Q�B��'�A��a��Q������	��C��A��K� ��"���9��>�%�Q�}�Q�W�'=�%=�r�5�y�I�I��I��	��	�)�3�/�/r1c�$�\rSrSrSrSrSrSrg)�
_Log10Memoizei�z�Class to compute, store, and allow retrieval of, digits of the
constant log(10) = 2.302585....  This constant is needed by
Decimal.ln, Decimal.log10, Decimal.exp and Decimal.__pow__.c��SUlg)N�/23025850929940456840179914546843642076011014886�r�r�s r/r�_Log10Memoize.__init__�s	��G��r1c�D�US:a[S5eU[UR5:�a\SnSX-S--n[[	[SU-U5S55nXB*SSU-:waOUS-
nM@UR
S5SS	Ul[URSUS
-5$)zdGiven an integer p >= 0, return floor(10**p)*log(10).

For example, self.getdigits(3) returns 2302.
r(zp should be nonnegativer�rr�r�Nr�r�r2)r�r�r�r�rr'rr�)r7r�rr!r�s     r/�	getdigits�_Log10Memoize.getdigits�s���
�q�5��6�7�7���D�K�K� � ��E�������O���\�%��1��a�.�#�>�?���&�'�?�c�%�i�/����
��
�!�-�-��,�S�b�1�D�K��4�;�;�t��!��$�%�%r1r3N)r<r=r>r?r@rr6rAr-r1r/r0r0�s��C�H�&r1r0c�H�[X-U-5n[S[[U55-SU--5*n[	X5nX-n[US-
SS5Hn[	XU--Xg-5nM [US-
SS5HnXS--n[	XUU--U5nM X-$)z�Given integers x and M, M > 0, such that x/M is small in absolute
value, compute an integer approximation to M*exp(x/M).  For 0 <=
x/M <= 2.4, the absolute error in the result is bounded by 60 (and
is usually much smaller).r r�r2r(r�r�)r�r�r�r�rr�)	r�r!r"r#r$r�Mshiftr�r�s	         r/�_iexpr:�s���*	���q�y��A�

�S��S��V��_�q��s�
#�	$�$�A��Q��A�
�T�F�
�1�Q�3��2�
����Q�J����4����1�Q�3��B�
���q�S�����f�H��v�.�� �
�3�Jr1c	� �US-
n[SU[[U55-S-
5nX#-nX-nUS:�a	USU--nO	USU*--n[U[	U55upx[USU-5n[[
USU-5S5Xr-
S-4$)a�Compute an approximation to exp(c*10**e), with p decimal places of
precision.

Returns integers d, f such that:

  10**(p-1) <= d <= 10**p, and
  (d-1)*10**f < exp(c*10**e) < (d+1)*10**f

In other words, d*10**f is an approximation to exp(c*10**e) with p
digits of precision, and with an error in d of at most 1.  This is
almost, but not quite, the same as the error being < 1ulp: when d
= 10**(p-1) the error could be up to 10 ulp.r�r(r2ri�r�)rPr�r�rfr)rr:)	r=r6r�rrnrg�cshift�quotr
s	         r/rkrk�s�����F�A�
��1�s�3�q�6�{�?�Q�&�'�E�	�	�A�
�C�E���z��2�u�9����B���J����v�}�Q�/�0�I�D��s�B��I�
&�C���c�2�q�5�)�4�0�$�(�Q�,�>�>r1c��[[[U555U-n[XXE-S-5nX5-
nUS:�aXb-SU--nO[	Xb-SU*-5nUS:XaA[[U55U-S:�US:�:XaSUS-
-S-SU-
p�X�4$SU-S-
U*p�X�4$[X�S-*US-5up�[	U	S5n	U
S-
n
X�4$)aGiven integers xc, xe, yc and ye representing Decimals x = xc*10**xe and
y = yc*10**ye, compute x**y.  Returns a pair of integers (c, e) such that:

  10**(p-1) <= c <= 10**p, and
  (c-1)*10**e < x**y < (c+1)*10**e

in other words, c*10**e is an approximation to x**y with p digits
of precision, and with an error in c of at most 1.  (This is
almost, but not quite, the same as the error being < 1ulp: when c
== 10**(p-1) we can only guarantee error < 10ulp.)

We assume that: x is positive and not equal to 1, and y is nonzero.
r2r(r)r�r�r�r�rrk)rrrrr�r��lxcrg�pcr�r�s           r/rrs��� 	�C��B��L��B��A�����A��
�C�
�D�E���z�
�V�B��I�
��
�#�&�"�u�f�*�
-��	�Q�w���R��\�B�
�!�
#��a��0��a��c��1��a��c�3��:��
�Q��q��1�"�3��:��	�2�1��v�q��s�+�
���U�B�'���q����:�r1r��F�5�(�r��rr�)	r_�2�3�4�5�6�7�8rtc�f�US::a[S5e[U5nS[U5-XS-
$)z@Compute a lower bound for 100*log10(c) for a positive integer c.r(z0The argument to _log10_lb should be nonnegative.r�)r�r�r�)r=�
correction�str_cs   r/r�r�*s:��	�A�v��K�L�L���F�E��s�5�z�>�J�Q�x�0�0�0r1c��[U[5(aU$[U[5(a[U5$U(a*[U[5(a[R	U5$U(a[SU-5e[$)z�Convert other to Decimal.

Verifies that it's ok to use in an implicit construction.
If allow_float is true, allow conversion from float;  this
is used in the comparison methods (__eq__ and friends).

r�)r�rr�r�r�r�r�)r�r�allow_floats   r/rr5sg���%��!�!����%�����u�~���z�%��/�/��!�!�%�(�(���9�E�A�B�B��r1c��[U[5(aX4$[U[R5(arUR(dJ[UR[[UR5UR-5UR5nU[UR54$U(a;[U[R5(aURS:XaURn[U[ 5(aR[#5nU(aSUR$[&'OUR)[&S5 U[R+U54$[,[,4$)z�Given a Decimal instance self and a Python object other, return
a pair (s, o) of Decimal instances such that "s op o" is
equivalent to "self op other" for any of the 6 comparison
operators "op".

r(r2r�)r�r�_numbers�Rationalr�rJrKr�r�rL�denominatorr��	numerator�Complexr�r�r�rr�rr�r�r�)r7r�r�r8s    r/r�r�Hs���%��!�!��{���%��*�*�+�+����#�D�J�J�$'��D�I�I���9J�9J�(J�$K�$(�I�I�/�D��W�U�_�_�-�-�-�
�z�%��)9�)9�:�:�u�z�z�Q���
�
���%�����,���,-�G�M�M�.�)�� � ��M�
O��W�'�'��.�.�.��>�)�)r1r�i?Bi���)rvrur�r�rwr}r~rr�)rvrur�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<no_neg_0>z)?
(?P<alt>\#)?
(?P<zeropad>0)?
(?P<minimumwidth>(?!0)\d+)?
(?P<thousands_sep>,)?
(?:\.(?P<precision>0|(?!0)\d+))?
(?P<type>[eEfFgGn%])?
\Z
c��[RU5nUc[SU-5eUR5nUSnUSnUSSLUS'US(a"Ub[SU-5eUb[SU-5eU=(d SUS'U=(d S	US'US
cSUS
'[	US=(d S
5US'USb[	US5US'USS:XaUSb	USS;aSUS'USS:XaKSUS'Uc[
R"5nUSb[SU-5eUSUS'USUS'USUS'U$UScSUS'SS/US'SUS'U$)a�Parse and validate a format specifier.

Turns a standard numeric format specifier into a dict, with the
following entries:

  fill: fill character to pad field to minimum width
  align: alignment type, either '<', '>', '=' or '^'
  sign: either '+', '-' or ' '
  minimumwidth: nonnegative integer giving minimum width
  zeropad: boolean, indicating whether to pad with zeros
  thousands_sep: string to use as thousands separator, or ''
  grouping: grouping for thousands separators, in format
    used by localeconv
  decimal_point: string to use for decimal point
  precision: nonnegative integer giving precision, or None
  type: one of the characters 'eEfFgG%', or None

NzInvalid format specifier: �fill�align�zeropadz7Fill character conflicts with '0' in format specifier: z2Alignment conflicts with '0' in format specifier: � �>r\r��minimumwidthr�rr(r��gGnr2rIr��
thousands_sepzJExplicit thousands separator conflicts with 'n' type in format specifier: �grouping�
decimal_pointr�r�r5)�_parse_format_specifier_regex�matchr��	groupdictr��_locale�
localeconv)�format_specr�r��format_dictrYrZs      r/rr�s
��&	&�+�+�K�8�A��y��5��C�D�D��+�+�-�K��v��D��� �E�)�)�4�D�@�K�	���9�����6�8C�D�E�
E����2�4?�@�A�
A��+�#�K���!�<�C�K����6��"�!��F��#&�k�.�&A�&H�S�"I�K����;��+�#&�{�;�'?�#@��K� ��;��1�$��v��&�+�f�*=��*F�'(�K��$��6��c�!�!��F����!�,�,�.�K���'�3��>�@K�L�M�
M�'2�?�'C��O�$�"-�j�"9��J��'2�?�'C��O�$�����'�/�+-�K��(�#$�a�&��J��'*��O�$��r1c��USnUSnXC[U5-
[U5-
-nUSnUS:Xa	X-U-nU$US:Xa	XP-U-nU$US:Xa	X-U-nU$US:Xa [U5S-nUS	UU-U-XXS	-nU$[S
5e)z�Given an unpadded, non-aligned numeric string 'body' and sign
string 'sign', add padding and alignment conforming to the given
format specifier dictionary 'spec' (as produced by
parse_format_specifier).

r^rYrZ�<r]�=�^r�NzUnrecognised alignment field)r�r�)	r\r
r	r^rY�paddingrZr��halfs	         r/rr&s�����'�L���<�D��3�t�9�,�s�4�y�8�9�G���M�E���|���w�&���M�
�#����$�&���M�
�#����$�&���M�

�#���7�|�Q�����$��$�&��-����>���M��7�8�8r1c���SSKJnJn U(d/$USS:Xa$[U5S:�aU"USSU"US55$US[R
:XaUSS$[
S5e)zqConvert a localeconv-style grouping into a (possibly infinite)
iterable of integers representing group lengths.

r()�chain�repeatr�r�Nrz unrecognised format for grouping)�	itertoolsrqrrr�rf�CHAR_MAXr�)rarqrrs   r/�_group_lengthsruAsl��(���	�	�"���	�s�8�}��1��X�c�r�]�F�8�B�<�$8�9�9�	�"���)�)�	)����}���;�<�<r1c���USnUSn/n[U5H�nUS::a[S5e[[[	U5US5U5nURSU[	U5-
-X*S-5 USU*nX&-nU(dUS::a ONU[	U5-nM� [[	U5US5nURSU[	U5-
-X*S-5 UR
[U55$)aFInsert thousands separators into a digit string.

spec is a dictionary whose keys should include 'thousands_sep' and
'grouping'; typically it's the result of parsing the format
specifier using _parse_format_specifier.

The min_width keyword argument gives the minimum length of the
result, which will be padded on the left with zeros if necessary.

If necessary, the zero padding adds an extra '0' on the left to
avoid a leading thousands separator.  For example, inserting
commas every three digits in '123456', with min_width=8, gives
'0,123,456', even though that has length 9.

r`rar(zgroup length should be positiver2r�N)rur�r)rPr�r�r��reversed)r�r	�	min_width�sepra�groupsr>s       r/�_insert_thousands_sepr{Xs���"��
�C��J��H�
�F�
�H�
%����6��>�?�?���C��K��A�.��2���
�
�c�1�s�6�{�?�+�f�R�S�k�9�:���!������	��)�q�.���S��X��	�&�
��F��Y��*���
�
�c�1�s�6�{�?�+�f�R�S�k�9�:��8�8�H�V�$�%�%r1c�0�U(agUSS;aUS$g)zDetermine sign character.r�r\z +r�r-)�is_negativer	s  r/rr}s#����	
�f���	��F�|��r1c�P�[X5nU(d
US(aUSU-nUS:wd	USS;a!SSSSS.USnUS	RXc5-
nUSS
:XaUS
-
nUS(aUS[U5-
[U5-
nOSn[XU5n[	XQU-U5$)
a/Format a number, given the following data:

is_negative: true if the number is negative, else false
intpart: string of digits that must appear before the decimal point
fracpart: string of digits that must come after the point
exp: exponent, as an integer
spec: dictionary resulting from parsing the format specifier

This function uses the information in spec to:
  insert separators (decimal separator and thousands separators)
  format the sign
  format the exponent
  add trailing '%' for the '%' type
  zero-pad if necessary
  fill and align if necessary
�altrbr(r�rr7r6)r7r6r�r�z{0}{1:+}r�r[r^)r�formatr�r{r)r}r�r�r�r	r\�echarrxs        r/rr�s���$��*�D��4��;���(�8�3��
�a�x�4��<�4�'���#�C�8��f��F���J�%�%�e�1�1���F�|�s���C����I����(�3�x�=�8�3�t�9�D�	��	�#�G�9�=�G���x�/��6�6r1�Infz-Infr3r�r�r,)F)r()r�)FF)r2)|r@�__all__r<�	__xname__�__version__�__libmpdec_version__�mathr��numbersrS�sys�collectionsr)�_namedtupler�ImportErrorrrrrrrrrr%r&�maxsizer!r"r#r$�ArithmeticErrorrr	r
r�ZeroDivisionErrorrrrrrr
rrrr�rrrbrC�contextvars�
ContextVarr��	frozensetr�rrr r�rrJ�Number�registerr�rr�rRr�r�r�r�rrrr'r�r�r0r6r)r:rkrr�rr�rrr�re�compile�VERBOSE�
IGNORECASErdr�r�r��DOTALLrc�localerfrrrur{rrr�r�rNrYrrXrZ�	hash_info�modulusrr�rr��_PyHASH_NANrr r-r1r/�<module>r�s��� '�!��F
�	���������
�&�5��~�/E�i�X�L�
�
��
�#���
�����#��
�
������;�;�'��!�H�!�H�"�H��H��H��H����
�#�	�
��
�.
��
��'��:�'��%�%�'8�%� 	�)�	�	�(�*;�	�
��
��%��
��
�	� �	�#:�w��#:�L
���)�
�
�%�y�
� 
�^�W�h���'��N�D��#�#3�$�%5�#�$4� �!1�3���}�o�}���/�:�G���"�-�-�.?�@���O����&��+�hB4K�f�B4K�Hh�&	������!�

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

����3�*

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

?>