config root man

Current Path : /compat/linux/proc/self/root/usr/local/lib/python2.5/

FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64
Upload File :
Current File : //compat/linux/proc/self/root/usr/local/lib/python2.5/decimal.pyc

hRc@sdZddddddddd	d
ddd
ddddddddddddgZddkZdZdZdZdZdZdZ	dZ
dZdefdYZ
de
fdYZde
fdYZdefd YZd	e
efd!YZd"efd#YZd$eefd%YZd
e
fd&YZd'efd(YZde
fd)YZde
fd*YZd
eefd+YZdeeefd,YZeeeeeeeegZhee<ee<ee<ee<ZyddkZWnDej
o8ddkZd-e fd.YZ!e!Z[[!nXyei"WnKe#j
o?e$ei%d/oei%`&nd0Z'd1Z(nFXei"Z"e$e"d/o
e"`&ne"d2Z(e"d3Z'[["e)d4Z*de fd5YZ+e,d6Z-gZ.e+i/i0D]!Z1e1i2d7oe.e1nq>[.Z3x8e3D]0Z1e1d8i4Z5e6e5Z7e1e+i8e7<qoW[1[7[5[3d9e fd:YZ9de fd;YZ:d<e fd=YZ;d>d?Z<hd@dA<dBdC<dDdE<dDdF<d8dG<d8dH<d8dI<d8dJ<d>dK<d>dL<d>dM<d>dN<d>dO<d>dP<d>dQ<d>dR<dSZ=dTZ>dUZ?dVZ@dWdXZAdYZBdZZCd[e fd\YZDeDiEZFdWd]ZGd^ZHd_ZIhd`dC<dadE<dbdF<dcdG<dddH<dedI<dfdJ<dgdK<dhdL<diZJe,djZKe:dkdldmedneeegdogdpdqdrdsdtd8ZLe:dkdudmedneeeeegdogZMe:dkdudmedngdogZNddkOZOddkOZOeOiPdveOiQeOiRBiSZTeOiPdwiSZUeOiPdxiSZV[Oe+dyZWe+dzZXe+d{ZYe+d>ZZe+d8Z[e+dZ\eWeXfZ]e^d|jo0ddk_Z_ddkZe_i`eiae^ndS(}s	
This is a Py2.3 implementation of decimal floating point arithmetic based on
the General Decimal Arithmetic Specification:

    www2.hursley.ibm.com/decimal/decarith.html

and IEEE standard 854-1987:

    www.cs.berkeley.edu/~ejr/projects/754/private/drafts/854-1987/dir.html

Decimal floating point has finite precision with arbitrarily large bounds.

The purpose of this module is to support arithmetic using familiar
"schoolhouse" rules and to avoid some of the tricky representation
issues associated with binary floating point.  The package is especially
useful for financial applications or for contexts where users have
expectations that are at odds with binary floating point (for instance,
in binary floating point, 1.00 % 0.1 gives 0.09999999999999995 instead
of the expected Decimal("0.00") returned by decimal floating point).

Here are some examples of using the decimal module:

>>> from decimal import *
>>> setcontext(ExtendedContext)
>>> Decimal(0)
Decimal("0")
>>> Decimal("1")
Decimal("1")
>>> Decimal("-.0123")
Decimal("-0.0123")
>>> Decimal(123456)
Decimal("123456")
>>> Decimal("123.45e12345678901234567890")
Decimal("1.2345E+12345678901234567892")
>>> Decimal("1.33") + Decimal("1.27")
Decimal("2.60")
>>> Decimal("12.34") + Decimal("3.87") - Decimal("18.41")
Decimal("-2.20")
>>> dig = Decimal(1)
>>> print dig / Decimal(3)
0.333333333
>>> getcontext().prec = 18
>>> print dig / Decimal(3)
0.333333333333333333
>>> print dig.sqrt()
1
>>> print Decimal(3).sqrt()
1.73205080756887729
>>> print Decimal(3) ** 123
4.85192780976896427E+58
>>> inf = Decimal(1) / Decimal(0)
>>> print inf
Infinity
>>> neginf = Decimal(-1) / Decimal(0)
>>> print neginf
-Infinity
>>> print neginf + inf
NaN
>>> print neginf * inf
-Infinity
>>> print dig / 0
Infinity
>>> getcontext().traps[DivisionByZero] = 1
>>> print dig / 0
Traceback (most recent call last):
  ...
  ...
  ...
DivisionByZero: x / 0
>>> c = Context()
>>> c.traps[InvalidOperation] = 0
>>> print c.flags[InvalidOperation]
0
>>> c.divide(Decimal(0), Decimal(0))
Decimal("NaN")
>>> c.traps[InvalidOperation] = 1
>>> print c.flags[InvalidOperation]
1
>>> c.flags[InvalidOperation] = 0
>>> print c.flags[InvalidOperation]
0
>>> print c.divide(Decimal(0), Decimal(0))
Traceback (most recent call last):
  ...
  ...
  ...
InvalidOperation: 0 / 0
>>> print c.flags[InvalidOperation]
1
>>> c.flags[InvalidOperation] = 0
>>> c.traps[InvalidOperation] = 0
>>> print c.divide(Decimal(0), Decimal(0))
NaN
>>> print c.flags[InvalidOperation]
1
>>>
tDecimaltContexttDefaultContexttBasicContexttExtendedContexttDecimalExceptiontClampedtInvalidOperationtDivisionByZerotInexacttRoundedt	SubnormaltOverflowt	Underflowt
ROUND_DOWNt
ROUND_HALF_UPtROUND_HALF_EVENt
ROUND_CEILINGtROUND_FLOORtROUND_UPtROUND_HALF_DOWNt
ROUND_05UPt
setcontextt
getcontexttlocalcontextiNcBseZdZdZRS(s-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 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.
    cGsdS(N((tselftcontexttargs((s#/usr/local/lib/python2.5/decimal.pythandles(t__name__t
__module__t__doc__R(((s#/usr/local/lib/python2.5/decimal.pyRscBseZdZRS(s)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").
    (RRR(((s#/usr/local/lib/python2.5/decimal.pyRs
cBseZdZdZRS(s0An 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.
    cGs?|o4t|di|didt}|i|SntS(Nitn(t_dec_from_triplet_signt_inttTruet_fix_nantNaN(RRRtans((s#/usr/local/lib/python2.5/decimal.pyRs#(RRRR(((s#/usr/local/lib/python2.5/decimal.pyRstConversionSyntaxcBseZdZdZRS(sTrying to convert badly formed string.

    This occurs and signals invalid-operation if an string is being
    converted to a number and it does not conform to the numeric string
    syntax.  The result is [0,qNaN].
    cGstS(N(R&(RRR((s#/usr/local/lib/python2.5/decimal.pyRs(RRRR(((s#/usr/local/lib/python2.5/decimal.pyR(scBseZdZdZRS(sDivision 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.
    cGst|S(N(tInfsign(RRtsignR((s#/usr/local/lib/python2.5/decimal.pyRs(RRRR(((s#/usr/local/lib/python2.5/decimal.pyRstDivisionImpossiblecBseZdZdZRS(sCannot 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].
    cGstS(N(R&(RRR((s#/usr/local/lib/python2.5/decimal.pyRs(RRRR(((s#/usr/local/lib/python2.5/decimal.pyR+stDivisionUndefinedcBseZdZdZRS(sUndefined 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].
    cGstS(N(R&(RRR((s#/usr/local/lib/python2.5/decimal.pyRs(RRRR(((s#/usr/local/lib/python2.5/decimal.pyR,scBseZdZRS(sHad 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.
    (RRR(((s#/usr/local/lib/python2.5/decimal.pyR	s
tInvalidContextcBseZdZdZRS(sInvalid 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].
    cGstS(N(R&(RRR((s#/usr/local/lib/python2.5/decimal.pyRs(RRRR(((s#/usr/local/lib/python2.5/decimal.pyR-s	cBseZdZRS(sNumber 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.
    (RRR(((s#/usr/local/lib/python2.5/decimal.pyR
!s
cBseZdZRS(sExponent < 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.
    (RRR(((s#/usr/local/lib/python2.5/decimal.pyR-s	cBseZdZdZRS(sNumerical 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.
    cGs|ittttfjot|Sn|djoE|itjot|Snt|d|i|i	|idSn|djoE|it
jot|Snt|d|i|i	|idSndS(Nit9i(troundingRRRRR)RR!tprectEmaxR(RRR*R((s#/usr/local/lib/python2.5/decimal.pyRNs

(RRRR(((s#/usr/local/lib/python2.5/decimal.pyR8scBseZdZRS(sxNumerical 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.
    (RRR(((s#/usr/local/lib/python2.5/decimal.pyR
^s
t
MockThreadingcBseZedZRS(cCs|itS(N(tmodulesR(Rtsys((s#/usr/local/lib/python2.5/decimal.pytlocals(RRR4R5(((s#/usr/local/lib/python2.5/decimal.pyR2st__decimal_context__cCsC|tttfjo|i}|in|ti_dS(s%Set this thread's context to context.N(RRRtcopytclear_flagst	threadingt
currentThreadR6(R((s#/usr/local/lib/python2.5/decimal.pyRscCsGytiiSWn/tj
o#t}|ti_|SnXdS(sReturns 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.
        N(R9R:R6tAttributeErrorR(R((s#/usr/local/lib/python2.5/decimal.pyRs	cCs;y|iSWn)tj
ot}||_|SnXdS(sReturns 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.
        N(R6R;R(t_localR((s#/usr/local/lib/python2.5/decimal.pyRs		cCs=|tttfjo|i}|in||_dS(s%Set this thread's context to context.N(RRRR7R8R6(RR<((s#/usr/local/lib/python2.5/decimal.pyRscCs$|djo
t}nt|S(sReturn 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

    N(tNoneRt_ContextManager(tctx((s#/usr/local/lib/python2.5/decimal.pyRs(

cBseZdZdmZddndZdZdZdndnd	Zd
Z	dZ
dZd
ZdndZ
dZdZdZedndZdndZdndZdndZedndZdndZeZdndZdndZdndZeZdndZeZdZ dndZ!e!Z"dndZ#dndZ$dnd Z%dnd!Z&dnd"Z'dnd#Z(dnd$Z)d%Z*d&Z+d'Z,d(Z-d)Z.hZ/d*Z0d+Z1d,Z2d-Z3d.Z4d/Z5d0Z6d1Z7dnd2Z8dnd3Z9d4Z:dndnd5Z;dnd6Z<dnd7Z=dndned8Z>d9Z?d:Z@dndnd;ZAdndnd<ZBeBZCdnd=ZDdnd>ZEdnd?ZFd@ZGdAZHdBZIdndCZJdndDZKdEZLdFZMdGZNdHZOdIZPdndJZQdKZRdLZSdMZTdNZUdndOZVdPZWdQZXdRZYdndSZZdTZ[dUZ\dndVZ]dWZ^dndXZ_dndYZ`dZZad[Zbdnd\Zcdnd]Zddnd^Zednd_Zfdnd`ZgdndaZhdndbZidndcZjdnddZkdndeZldfZmdndgZndndhZodndiZpdjZqdkZrdlZsRS(os,Floating point class for decimal arithmetic.t_expR#R"t_is_specialt0cCsti|}t|tot|}|djo2|djo
t}n|itd|Sn|i	ddjo
d|_
n
d|_
|i	d}|dj	o|i	d}t|i	dpd	}|dj	o:t||i
d	pd	|_|t||_n)t|i
d	pd	|_||_t|_nz|i	d
}|dj	oBt|i
d	|_|i	do
d|_qd
|_nd	|_d|_t|_|Snt|ttfoR|djo
d|_
n
d|_
d|_tt||_t|_|Snt|to8|i|_|i
|_
|i|_|i|_|Snt|toA|i|_
t|i|_t|i|_t|_|Snt|ttfot|djotdnt|dttfo|ddjptdn|d|_
|ddjo#d	|_|d|_t|_n0g}	x{|dD]o}
t|
ttfoGd|
jo
djno)|	p
|
djo|	i|
qqtdqW|ddjo5ditt|	|_|d|_t|_nft|dttfo?ditt|	pdg|_|d|_t|_n
td|Snt|t ot!ddnt!d|dS(sCreate 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 or long
        Decimal("314")
        >>> Decimal(Decimal(314))        # another decimal instance
        Decimal("314")
        sInvalid literal for Decimal: %rR*t-iitinttfractexpRBtdiagtsignaltNR tFistInvalid tuple size in creation of Decimal from list or tuple.  The list or tuple should have exactly three elements.s|Invalid sign.  The first value in the tuple should be an integer; either 0 for a positive number or 1 for a negative number.ii	sTThe second value in the tuple must be composed of integers in the range 0 through 9.tsUThe third value in the tuple must be an integer, or one of the strings 'F', 'n', 'N'.s"Cannot convert float to Decimal.  s#First convert the float to a stringsCannot convert %r to DecimalN(ii(R RI("tobjectt__new__t
isinstancet
basestringt_parserR=Rt_raise_errorR(tgroupR"RDtstrtlstripR#tlenR@tFalseRAR$tlongtabsRt_WorkRepR*RFtlistttuplet
ValueErrortappendtjointmaptfloatt	TypeError(tclstvalueRRtmtintparttfracpartRFRGtdigitstdigit((s#/usr/local/lib/python2.5/decimal.pyRMs


	
	

#	



			

				+
	

4

%

cCsE|io7|i}|djodSqA|djodSqAndS(srReturns whether the number is not actually one.

        0 if a number
        1 if NaN
        2 if sNaN
        R iRIii(RAR@(RRF((s#/usr/local/lib/python2.5/decimal.pyt_isnans
	

cCs.|idjo|iodSndSndS(syReturns whether the number is infinite

        0 if finite or not a number
        1 if +INF
        -1 if -INF
        RJiii(R@R"(R((s#/usr/local/lib/python2.5/decimal.pyt_isinfinitys

cCs|i}|djo
t}n
|i}|p|o|djo
t}n|djo|itd|Sn|djo|itd|Sn|o|i|Sn|i|SndS(sReturns 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.
        itsNaNiN(RiR=RVRRQRR%(RtotherRtself_is_nantother_is_nan((s#/usr/local/lib/python2.5/decimal.pyt_check_nanss"






cCs|ip
|idjS(suReturn True if self is nonzero; otherwise return False.

        NaNs and infinities are considered nonzero.
        RB(RAR#(R((s#/usr/local/lib/python2.5/decimal.pyt__nonzero__scCst|}|tjodSn|ip
|io?|ip
|iodSnt|i|iSn|p|pdSqd|iSn|pd|iSn|i|ijodSn|i|ijodSn|i}|i}||joR|id|i	|i	}|id|i	|i	}t||d|iSn)||jod|iSn
d|iSdS(NiiiRB(
t_convert_othertNotImplementedRARitcmpRjR"tadjustedR#R@(RRlt
self_adjustedtother_adjustedtself_paddedtother_padded((s#/usr/local/lib/python2.5/decimal.pyt__cmp__s4


cCs4t|tttfptSn|i|djS(Ni(RNRRDRWRrRy(RRl((s#/usr/local/lib/python2.5/decimal.pyt__eq__scCs4t|tttfptSn|i|djS(Ni(RNRRDRWRrRy(RRl((s#/usr/local/lib/python2.5/decimal.pyt__ne__scCset|dt}|ip|o/|io%|i||}|o|SqRnt|i|S(sCompares one to another.

        -1 => a < b
        0  => a = b
        1  => a > b
        NaN => one is NaN
        Like __cmp__, but returns Decimal instances.
        traiseit(RqR$RARoRRy(RRlRR'((s#/usr/local/lib/python2.5/decimal.pytcompares	cCs|io1|iotdntt|Sn|pdSn|io9t|i}td|i|i	d|i
Snt|i|it
|i|iidfS(sx.__hash__() <==> hash(x)sCannot hash a NaN value.iii
RB(RARiRathashRSt
_isintegerRYtto_integral_valueR*RDRFR"R@RUR#trstrip(Rtop((s#/usr/local/lib/python2.5/decimal.pyt__hash__s


'	cCs%|ittt|i|ifS(seRepresents the number as a triple tuple.

        To show the internals exactly as they are.
        (R"R[R_RDR#R@(R((s#/usr/local/lib/python2.5/decimal.pytas_tuple,scCsdt|S(s0Represents the number as an instance of Decimal.s
Decimal("%s")(RS(R((s#/usr/local/lib/python2.5/decimal.pyt__repr__3sc	Csddg|i}|ioR|idjo|dSqo|idjo|d|iSqo|d|iSn|it|i}|idjo|d	jo
|}nJ|p
d
}n9|idjo|d
dd
}n|d
dd
}|djo d}d
d||i}n]|t|ijo(|id|t|i}d}n|i| }d
|i|}||jo
d}n:|djo
t}nddg|id||}||||S(sReturn string representation of the number in scientific notation.

        Captures all of the information in the underlying representation.
        RKRCRJtInfinityR R&RkiiiRBit.tetEs%+dN(R"RAR@R#RUR=Rtcapitals(	RtengRR*t
leftdigitstdotplaceReRfRF((s#/usr/local/lib/python2.5/decimal.pyt__str__8s:









cCs|idtd|S(sConvert to engineering-type string.

        Engineering notation has an exponent which is a multiple of 3, so there
        are up to 3 digits left of the decimal place.

        Same rules for when in exponential and when as a value as in __str__.
        RR(RR$(RR((s#/usr/local/lib/python2.5/decimal.pyt
to_eng_stringlscCsy|io%|id|}|o|Sq/n|p|i}n
|i}|djo
t}n|i|S(sRReturns a copy with the sign switched.

        Rounds, if it has reason.
        RN(RARotcopy_abstcopy_negateR=Rt_fix(RRR'((s#/usr/local/lib/python2.5/decimal.pyt__neg__vs


cCsy|io%|id|}|o|Sq/n|p|i}n
t|}|djo
t}n|i|S(shReturns a copy, unless it is a sNaN.

        Rounds the number (if more then precision digits)
        RN(RARoRRR=RR(RRR'((s#/usr/local/lib/python2.5/decimal.pyt__pos__s


cCsz|p|iSn|io%|id|}|o|SqDn|io|id|}n|id|}|S(sReturns 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(RRARoR"RR(RtroundRR'((s#/usr/local/lib/python2.5/decimal.pyt__abs__s

c
Cst|}|tjo|Sn|djo
t}n|ip
|io|i||}|o|Sn|ioB|i|ijo!|io|it	dSnt
|Sn|iot
|Sqnt|i|i}d}|i
tjo|i|ijo
d}n|oW|oOt|i|i}|o
d}nt|d|}|i|}|Sn|pIt||i|id}|i||i
}|i|}|Sn|pIt||i|id}|i||i
}|i|}|Snt|}t|}t|||i\}}t}	|i|ijo|i|ijo)t|d|}|i|}|Sn|i|ijo||}}n|idjo&d|	_|i|i|_|_qOd|	_n9|idjod|	_d\|_|_n
d|	_|idjo|i|i|	_n|i|i|	_|i|	_t
|	}|i|}|S(sbReturns self + other.

        -INF + INF (or the reverse) cause InvalidOperation errors.
        s
-INF + INFiiRBN(ii(RqRrR=RRARoRjR"RQRRtminR@R/RR!RtmaxR0t_rescaleRYt
_normalizeR*RDRF(
RRlRR'RFtnegativezeroR*top1top2tresult((s#/usr/local/lib/python2.5/decimal.pyt__add__s|



 
#

		
		cCsvt|}|tjo|Sn|ip
|io(|i|d|}|o|Sq]n|i|id|S(sReturn self - otherR(RqRrRARoRR(RRlRR'((s#/usr/local/lib/python2.5/decimal.pyt__sub__s
cCs4t|}|tjo|Sn|i|d|S(sReturn other - selfR(RqRrR(RRlR((s#/usr/local/lib/python2.5/decimal.pyt__rsub__s
cCst|}|tjo|Sn|djo
t}n|i|iA}|ip
|io|i||}|o|Sn|io'|p|it	dSnt
|Sn|io'|p|it	dSnt
|Sqn|i|i}|p|o)t|d|}|i
|}|Sn|idjo,t||i|}|i
|}|Sn|idjo,t||i|}|i
|}|Snt|}t|}t|t|i|i|}|i
|}|S(s\Return self * other.

        (+-) INF * 0 (or its reverse) raise InvalidOperation.
        s(+-)INF * 0s0 * (+-)INFRBt1N(RqRrR=RR"RARoRjRQRR)R@R!RR#RYRSRD(RRlRt
resultsignR't	resultexpRR((s#/usr/local/lib/python2.5/decimal.pyt__mul__"sH




"cCst|}|tjotSn|d
jo
t}n|i|iA}|ip
|io|i||}|o|Sn|io!|io|it	dSn|iot
|Sn|io*|itdt|d|i
Sqn|p2|p|itdSn|itd|Sn|p|i|i}d}n t|it|i|id}|i|i|}t|}t|}	|djo't|id||	i\}}
n%t|i|	id|\}}
|
o#|d	djo|d7}q{nK|i|i}x7||jo)|ddjo|d}|d7}qDWt|t||}|i|S(sReturn self / other.s(+-)INF/(+-)INFsDivision by infinityRBs0 / 0sx / 0iii
iN(RqRrR=RR"RARoRjRQRR)RR!tEtinyR,RR@RUR#R0RYtdivmodRDRSR(RRlRR*R'RFtcoefftshiftRRt	remaindert	ideal_exp((s#/usr/local/lib/python2.5/decimal.pyt__div__[sR





'
'$
cCs|i|iA}|io
|i}nt|i|i}|i|i}|p|ip
|djo)t|dd|i||ifSn||ijot	|}t	|}|i
|i
jo!|id|i
|i
9_n|id|i
|i
9_t|i|i\}}	|d|ijo5t|t
|dt|it
|	|fSqn|itd}
|
|
fS(sReturn (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.
        iRBii
s%quotient too large in //, % or divmod(R"RjR@RRtR!RR/R0RYRFRDRRSRQR+(RRlRR*RtexpdiffRRtqtrR'((s#/usr/local/lib/python2.5/decimal.pyt_divides*

"!$		cCs4t|}|tjo|Sn|i|d|S(s%Swaps self/other and returns __div__.R(RqRrR(RRlR((s#/usr/local/lib/python2.5/decimal.pyt__rdiv__s
cCsRt|}|tjo|Sn|djo
t}n|i||}|o||fSn|i|iA}|ioK|io |itd}||fSqt	||itdfSn|pP|p |it
d}||fSq!|itd||itdfSn|i||\}}|i
|}||fS(s6
        Return (self // other, self % other)
        sdivmod(INF, INF)sINF % xsdivmod(0, 0)sx // 0sx % 0N(RqRrR=RRoR"RjRQRR)R,RRR(RRlRR'R*tquotientR((s#/usr/local/lib/python2.5/decimal.pyt
__divmod__s0




cCs4t|}|tjo|Sn|i|d|S(s(Swaps self/other and returns __divmod__.R(RqRrR(RRlR((s#/usr/local/lib/python2.5/decimal.pyt__rdivmod__s
cCst|}|tjo|Sn|djo
t}n|i||}|o|Sn|io|itdSn7|p/|o|itdSq|itdSn|i	||d}|i
|}|S(s
        self % other
        sINF % xsx % 0s0 % 0iN(RqRrR=RRoRjRQRR,RR(RRlRR'R((s#/usr/local/lib/python2.5/decimal.pyt__mod__s"



cCs4t|}|tjo|Sn|i|d|S(s%Swaps self/other and returns __mod__.R(RqRrR(RRlR((s#/usr/local/lib/python2.5/decimal.pyt__rmod__s
cCs|djo
t}nt|dt}|i||}|o|Sn|io|itdSn|p/|o|itdSq|itdSn|iot	|}|i
|Snt|i|i}|p&t
|id|}|i
|Sn|i|i}||idjo|itSn|djo&|i||i}|i
|Snt|}t|}|i|ijo!|id|i|i9_n|id|i|i9_t|i|i\}}	d	|	|d@|ijo|	|i8}	|d7}n|d|ijo|itSn|i}
|	d
jod|
}
|	}	nt
|
t|	|}|i
|S(sI
        Remainder nearest to 0-  abs(remainder-near) <= other/2
        R|sremainder_near(infinity, x)sremainder_near(x, 0)sremainder_near(0, 0)RBiii
iiN(R=RRqR$RoRjRQRR,RRRR@R!R"RtR0R+RR/RYRFRDRRS(RRlRR'tideal_exponentRRRRRR*((s#/usr/local/lib/python2.5/decimal.pytremainder_nearsZ


			

!
	

cCst|}|tjo|Sn|djo
t}n|i||}|o|Sn|io7|io|itdSqt|i	|i	ASn|p<|o!|it
d|i	|i	ASq|itdSn|i||dS(s
self // others
INF // INFsx // 0s0 // 0iN(
RqRrR=RRoRjRQRR)R"RR,R(RRlRR'((s#/usr/local/lib/python2.5/decimal.pyt__floordiv__Ys$




cCs4t|}|tjo|Sn|i|d|S(s*Swaps self/other and returns __floordiv__.R(RqRrR(RRlR((s#/usr/local/lib/python2.5/decimal.pyt
__rfloordiv__us
cCstt|S(sFloat representation.(R`RS(R((s#/usr/local/lib/python2.5/decimal.pyt	__float__|scCs|ioH|iot}|itSqR|iotdqRnd|i}|idjo |t	|i
d|iSn |t	|i
|i pdSdS(s1Converts self to an int, truncating if necessary.sCannot convert infinity to longiii
RBN(RARiRRQR-Rjt
OverflowErrorR"R@RDR#(RRts((s#/usr/local/lib/python2.5/decimal.pyt__int__s

	

 cCst|iS(sCConverts to a long.

        Equivalent to long(int(self))
        (RWR(R((s#/usr/local/lib/python2.5/decimal.pyt__long__scCsp|i}|i|i}t||jo:|t||id}t|i||itSnt	|S(s2Decapitate the payload of a NaN to fit the contextRB(
R#R0t_clampRURTR!R"R@R$R(RRtpayloadtmax_payload_len((s#/usr/local/lib/python2.5/decimal.pyR%s	cCsR|io,|io|i|Sq6t|Sn|i}|i}|ps|i|g|i}tt	|i
||}||i
jo$|itt
|id|Sqt|Snt|i|i
|i}||jo4|it|it|itd|iSn||j}|o|it|}n|i
|jo|itt|i|i
|}|djo#t
|id|d}d}nt||i|i}	|	|}
|i| pd}|
djott|d}nt
|i||}|
o|it|o)|it|p|itqqt|i|idjoS|i
|jo't
|i|id |i
d}q|itd|i}qn|Sn|idjoL|i
|jo<|it|id|i
|}
t
|i|
|Snt|S(sRound 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.
        RBs
above EmaxiRii(RARiR%RRtEtopR1RRRR@RQRR!R"RUR#R0R	R
RRtgetattrt_pick_rounding_functionR/RSRDR
(RRRRtexp_maxtnew_exptexp_mintself_is_subnormalRgt
this_functiontchangedRR'Rw((s#/usr/local/lib/python2.5/decimal.pyRsh














	 
cCs#t|i|odSndSdS(s(Also known as round-towards-0, truncate.iiN(t
_all_zerosR#(RR0((s#/usr/local/lib/python2.5/decimal.pyt_round_downscCs|i|S(sRounds away from 0.(R(RR0((s#/usr/local/lib/python2.5/decimal.pyt	_round_up
scCs?|i|djodSn t|i|odSndSdS(sRounds 5 up (away from 0)t56789iiiN(R#R(RR0((s#/usr/local/lib/python2.5/decimal.pyt_round_half_ups
cCs,t|i|odSn|i|SdS(sRound 5 downiN(t_exact_halfR#R(RR0((s#/usr/local/lib/python2.5/decimal.pyt_round_half_downscCsQt|i|o-|djp|i|ddjodSn|i|SdS(s!Round 5 to even, rest to nearest.iit02468iN(RR#R(RR0((s#/usr/local/lib/python2.5/decimal.pyt_round_half_evens%cCs-|io|i|Sn|i|SdS(s(Rounds up (not away from 0 if negative.)N(R"R(RR0((s#/usr/local/lib/python2.5/decimal.pyt_round_ceiling&s
cCs-|ip|i|Sn|i|SdS(s'Rounds down (not towards 0 if negative)N(R"R(RR0((s#/usr/local/lib/python2.5/decimal.pyt_round_floor-s
cCsB|o)|i|ddjo|i|Sn|i|SdS(s)Round down unless digit prec-1 is 0 or 5.it05N(R#R(RR0((s#/usr/local/lib/python2.5/decimal.pyt_round_05up4scCst|dt}|ip
|io&|djo
t}n|idjo|itd|Sn|idjo|itd|Sn|idjo
|}q|idjo
|}q|idjo3|p|itdSnt|i	|i	A}q|idjo3|p|itdSnt|i	|i	A}qnCt
|i	|i	Att|i
t|i
|i|i}t|dt}|i||S(	s: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.
        R|RIRkR RJsINF * 0 in fmas0 * INF in fmaN(RqR$RAR=RR@RQRR)R"R!RSRDR#R(RRltthirdRtproduct((s#/usr/local/lib/python2.5/decimal.pytfma;s6



		cCst|dt}t|dt}|djo
t}n|i}|i}|i}|p|p|o|djo|itd|Sn|djo|itd|Sn|djo|itd|Sn|o|i|Sn|o|i|Sn|i|Sn|io|io
|ip|itdSn|djo|itdSn|p|itdSn|i	|i
jo|itdSn|o|o|itd	Sn|io
d}n
|i}t
t|}t|i}t|i}	|i|td
|i||}x)t|	iD]}
t|d
|}qsWt||	i|}t|t|dS(s!Three argument version of __pow__R|iRks@pow() 3rd argument not allowed unless all arguments are integersisApow() 2nd argument cannot be negative when 3rd argument specifiedspow() 3rd argument cannot be 0sSinsufficient precision: pow() 3rd argument must not have more than precision digitssXat least one of pow() 1st argument and 2nd argument must be nonzero ;0**0 is not definedi
N(RqR$R=RRiRQRR%RRtR0t_isevenR"RXRDRYRtpowRFtxrangeR!RS(RRltmoduloRRmRnt
modulo_is_nanR*tbasetexponentti((s#/usr/local/lib/python2.5/decimal.pyt
_power_modulogsf







	
				

	$cCst|}|i|i}}x*|ddjo|d}|d7}q"Wt|}|i|i}}x*|ddjo|d}|d7}qnW|djo|djo||d|}	n.t||d|\}	}
|
odSn|idjo|	}	n|io>|idjo.|it|}t	|	||d}nd}t
ddd||	|Sn|idjok|d}
|
djo||@|jodSnt|d}|djo&|d|}||}||}n\d|}t|||\}}
|
odSnt|||\}}
|
odSn|d
|djodSnd|}n4|
djo"t|d
d
}td||\}}
|
odSnx*|ddjo|d}|d8}qW|djo&|d|}||}||}n\d|}t|||\}}
|
odSnt|||\}}
|
odSn|d|djodSnd|}ndS|d|jodSn||}t
dt||Sn|djo|d|d}}n|djo,t
tt|||jodSnt|}|djo,t
tt|||jodSn|d|}}x?|d|djo
djno|d}|d}qWx?|d|djo
djno|d}|d}qW|djo|djo||jodSnt||\}}|djodSndt||>}xQtoIt|||d\}}||joPq||d||}qW||jo
|djpdSn|}n|djo#||dt|jodSn||}||9}|d|jodSnt|}|ioD|idjo4|it|}t	|||t
|}nd}t
d|d|||S(shAttempt 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.i
iiRRBiiiiiAi]iiilidN(iiii(RYRDRFRR=R*RR"R@RR!t_nbitsRSRURXR$t	_log10_lb(RRltptxtxctxetytyctyeRRRtzerost
last_digitRty_as_inttten_powty_as_integerRdR txc_bitstremtaRRtstr_xc((s#/usr/local/lib/python2.5/decimal.pyt_power_exacts;



 








11&
&




(

!cCs|d
j	o|i|||Snt|}|tjo|Sn|d
jo
t}n|i||}|o|Sn|p#|p|itdSqtSnd}|i	djoS|i
o|ip
d}qn|o|itdSn|i}n|p0|i	djot
|ddSqJt|Sn|io0|i	djot|Sqt
|ddSn|tjo|i
o|i	djo
d}n*||ijo
|i}n
t|}|i|}|d|ijod|i}|itqNn(|it|itd|i}t
|dd||Sn|i}|io<|i	dj|djjot
|ddSqt|Snd
}|i|i}	|dj|i	djjo=|	tt|ijot
|d|id}qunA|i}
|	tt|
jot
|d|
d}n|d
joS|i||id}|d
j	o)|djot
d|i|i}qn|d
jo|i}t|}|i|i}
}t|}|i|i}}|idjo|}nd}xdt o\t!|
|||||\}}|dd	tt||doPn|d7}qMWt
|t||}n|i
p|itt|i|ijoE|idt|i}t
|i	|id||i|}n|i|i"jo|it#qpn|i$|}|S(sHReturn 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.
        s0 ** 0iis+x ** y with x negative and y not an integerRBRiii
N(%R=RRqRrRRoRQRtDec_p1R"RRRR!R)RjR0RDR@R
R	Rtt_log10_exp_boundRURSR1RRR#RYRFR*R$t_dpowertEminR
R(RRlRRR'tresult_signt
multiplierRFtself_adjtboundRRRRRRRRtextraRR((s#/usr/local/lib/python2.5/decimal.pyt__pow__s





	










!
 
	"'

cCs4t|}|tjo|Sn|i|d|S(s%Swaps self/other and returns __pow__.R(RqRrR(RRlR((s#/usr/local/lib/python2.5/decimal.pyt__rpow__Fs
cCs|djo
t}n|io%|id|}|o|SqIn|i|}|io|Sn|pt|iddSn|i|i	g|i
}t|i}|i
}x>|i|ddjo%||jo|d7}|d8}qWt|i|i| |S(s?Normalize- strip trailing 0s, change anything equal to 0 to 0e0RRBiiN(R=RRARoRRjR!R"R1RRRUR#R@(RRR'tdupRtendRF((s#/usr/local/lib/python2.5/decimal.pyt	normalizeMs&



	%
cCst|dt}|djo
t}n|djo
|i}n|ip
|io{|i||}|o|Sn|ip
|io<|io|iot|Sn|i	t
dSqn|p_|i|i|}|i|ijo/|i	t
||jo|i	tq3n|Sn|i|ijo
|ijnp|i	t
dSn|p)t|id|i}|i|Sn|i}||ijo|i	t
dSn||id|ijo|i	t
dSn|i|i|}|i|ijo|i	t
dSnt|i|ijo|i	t
dSn|i|ijo/|i	t
||jo|i	tqn|o'|i|ijo|i	tn|i|}|S(	sQuantize self so its exponent is the same as that of exp.

        Similar to self._rescale(exp._exp) but with error checking.
        R|squantize with one INFs)target exponent out of bounds in quantizeRBs9exponent of quantize result too large for current contextis7quantize result has too many digits for current contextN(RqR$R=RR/RARoRjRRQRRR@R
R	RR1R!R"RRtR0RUR#RR(RRFR/RtwatchexpR'Ru((s#/usr/local/lib/python2.5/decimal.pytquantizefsb



	

*					

cCskt|dt}|ip
|io5|io
|ip|io
|iSn|i|ijS(s=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.
        R|(RqR$RAtis_nantis_infiniteR@(RRl((s#/usr/local/lib/python2.5/decimal.pytsame_quantums
	cCs)|iot|Sn|pt|id|Sn|i|jo)t|i|id|i||Snt|i|i|}|djo#t|id|d}d}nt||i|}||}|i| pd}|djot	t
|d}nt|i||S(ssRescale 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
        RBiRi(RARR!R"R@R#RURRRSRD(RRFR/RgRRR((s#/usr/local/lib/python2.5/decimal.pyRs"
	 


cCs|io/|id|}|o|Snt|Sn|idjot|Sn|pt|iddSn|djo
t}n|djo
|i}n|i	t
|id|}||jo|i	tn|S(sVRounds 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.
        RiRBN(
RARoRR@R!R"R=RR/RQR
RR	(RR/RR'((s#/usr/local/lib/python2.5/decimal.pytto_integral_exacts$







cCs|djo
t}n|djo
|i}n|io/|id|}|o|Snt|Sn|idjot|Sn|id|SdS(s@Rounds to the nearest integer, without raising inexact, rounded.RiN(R=RR/RARoRR@R(RR/RR'((s#/usr/local/lib/python2.5/decimal.pyRs




cCs|d
jo
t}n|ioP|id|}|o|Sn|io|idjot|Sqtn|p-t|id|id}|i	|Sn|idjo|i
tdSn|id}t
|}|id?}|id@o(|id}t|id?d}n!|i}t|idd?}||}|djo|d|9}t}	n"t|d|\}}
|
}	||8}d|}x6to.||}||joPq||d?}qW|	o|||j}	|	o<|djo|d|}n|d|9}||7}n |d	djo|d7}ntdt||}|i}|it}
|i	|}|
|_|S(sReturn the square root of self.RiRBiissqrt(-x), x > 0i
idiN(R=RRARoRjR"RR!R@RRQRR0RYRFRDRUR#R$RRSt
_shallow_copyt
_set_roundingRR/(RRR'R0RRtctlRtexactRR RR/((s#/usr/local/lib/python2.5/decimal.pytsqrt
	sb





	







	cCs-t|dt}|djo
t}n|ip
|io|i}|i}|p|oj|djo|djo|i|Sn|djo|djo|i|Sn|i||Sqn|i|}|djo|i	|}n|djo
|}n|}|i|S(sReturns the larger value.

        Like max(self, other) except if one is not a number, returns
        NaN (and signals if one is sNaN).  Also rounds.
        R|iiiN(
RqR$R=RRARiRRoRyt
compare_total(RRlRtsntonRR'((s#/usr/local/lib/python2.5/decimal.pyRp	s&


	

cCs-t|dt}|djo
t}n|ip
|io|i}|i}|p|oj|djo|djo|i|Sn|djo|djo|i|Sn|i||Sqn|i|}|djo|i	|}n|djo
|}n|}|i|S(sReturns the smaller value.

        Like min(self, other) except if one is not a number, returns
        NaN (and signals if one is sNaN).  Also rounds.
        R|iiiN(
RqR$R=RRARiRRoRyR(RRlRRRRR'((s#/usr/local/lib/python2.5/decimal.pyR	s&




cCsN|iotSn|idjotSn|i|i}|dt|jS(s"Returns whether self is an integeriRB(RARVR@R$R#RU(Rtrest((s#/usr/local/lib/python2.5/decimal.pyR	s
cCs8|p|idjotSn|id|idjS(s:Returns True if self is even.  Assumes self is an integer.iiR(R@R$R#(R((s#/usr/local/lib/python2.5/decimal.pyR	scCs:y|it|idSWntj
odSnXdS(s$Return the adjusted exponent of selfiiN(R@RUR#Ra(R((s#/usr/local/lib/python2.5/decimal.pyRt	scCs|S(sReturns the same Decimal object.

        As we do not have different encodings for the same number, the
        received object already is in its canonical form.
        ((RR((s#/usr/local/lib/python2.5/decimal.pyt	canonical	scCs|djo
t}n|i}|i}|djo|itd|Sn|djo|itd|Sn|o|itd|Sn|o|itd|Sn|i|d|S(sCompares self to the other operand numerically.

        It's pretty much like compare(), but all NaNs signal, with signaling
        NaNs taking precedence over quiet NaNs.
        iRksNaN in compare_signalRN(R=RRiRQRR}(RRlRRmRn((s#/usr/local/lib/python2.5/decimal.pytcompare_signal	s"



cCs|io|iotSn|io|iotSn|i}|i}|i}|p|o ||jo\|i|ijo|otSqtSn|i|ijo|otSqtSntSn|oX|djotSn|djotSn|djotSn|djotSqq|djotSn|djotSn|djotSn|djotSqn||jotSn||jotSn|i|ijo|otSqtSn|i|ijo|otSqtSntS(sCompares 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.
        ii(R"tDec_n1RRiR#tDec_0R@(RRlR*tself_nant	other_nan((s#/usr/local/lib/python2.5/decimal.pyR	s`	










cCs%|i}|i}|i|S(sCompares self to other using abstract repr., ignoring sign.

        Like compare_total, but with operand's sign ignored and assumed to be 0.
        (RR(RRlRto((s#/usr/local/lib/python2.5/decimal.pytcompare_total_mag8
scCstd|i|i|iS(s'Returns a copy with the sign set to 0. i(R!R#R@RA(R((s#/usr/local/lib/python2.5/decimal.pyRA
scCsJ|io td|i|i|iSntd|i|i|iSdS(s&Returns a copy with the sign inverted.iiN(R"R!R#R@RA(R((s#/usr/local/lib/python2.5/decimal.pyRE
s
 cCst|i|i|i|iS(s$Returns self with the sign of other.(R!R"R#R@RA(RRl((s#/usr/local/lib/python2.5/decimal.pyt	copy_signL
scCs|djo
t}n|id|}|o|Sn|idjotSn|ptSn|idjot|Sn|i}|i}|i	djoA|t
t|iddjot
dd|id}n|i	djoH|t
t|iddjo t
dd|id}nD|i	djo5||jo't
ddd|dd|}n|i	djo5||djo#t
dd|d|d}nt|}|i|i}}|idjo|}nd}x^toVt||||\}	}
|	d	d
t
t|	|doPn|d7}qWt
dt|	|
}|i}|it}|i|}||_|S(sReturns e ** self.RiiiiRRBR.ii
N(R=RRoRjRRRR0RtR"RURSR1R!RRYRDRFR*R$t_dexpRR
RRR/(RRR'RtadjRRRRRRFR/((s#/usr/local/lib/python2.5/decimal.pyRFQ
sL

	48 '"#'	cCstS(sReturn 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.
        (R$(R((s#/usr/local/lib/python2.5/decimal.pytis_canonical
scCs|iS(sReturn True if self is finite; otherwise return False.

        A Decimal instance is considered finite if it is neither
        infinite nor a NaN.
        (RA(R((s#/usr/local/lib/python2.5/decimal.pyt	is_finite
scCs
|idjS(s8Return True if self is infinite; otherwise return False.RJ(R@(R((s#/usr/local/lib/python2.5/decimal.pyR	
scCs
|idjS(s>Return True if self is a qNaN or sNaN; otherwise return False.R RI(R RI(R@(R((s#/usr/local/lib/python2.5/decimal.pyR
scCs[|ip|otSn|djo
t}n|i|ijo
|ijnS(s?Return True if self is a normal number; otherwise return False.N(RARVR=RRRtR1(RR((s#/usr/local/lib/python2.5/decimal.pyt	is_normal
s


cCs
|idjS(s;Return True if self is a quiet NaN; otherwise return False.R (R@(R((s#/usr/local/lib/python2.5/decimal.pytis_qnan
scCs
|idjS(s8Return True if self is negative; otherwise return False.i(R"(R((s#/usr/local/lib/python2.5/decimal.pyt	is_signed
scCs
|idjS(s?Return True if self is a signaling NaN; otherwise return False.RI(R@(R((s#/usr/local/lib/python2.5/decimal.pytis_snan
scCsG|ip|otSn|djo
t}n|i|ijS(s9Return True if self is subnormal; otherwise return False.N(RARVR=RRtR(RR((s#/usr/local/lib/python2.5/decimal.pytis_subnormal
s


cCs|io
|idjS(s6Return True if self is a zero; otherwise return False.RB(RAR#(R((s#/usr/local/lib/python2.5/decimal.pytis_zero
scCs|it|id}|djo tt|dddSn|djo$ttd|dddSnt|}|i|i}}|djoCt|d|}t|}t|t|||jSn|ttd||dS(sCompute 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.
        iii
iii(R@RUR#RSRYRDRF(RR RRRtnumtden((s#/usr/local/lib/python2.5/decimal.pyt
_ln_exp_bound
s
 
$
"c
Cs|d	jo
t}n|id|}|o|Sn|ptSn|idjotSn|tjotSn|idjo|i	t
dSnt|}|i|i
}}|i}||id}xZtoRt|||}|ddttt||doPn|d7}qWtt|djtt||}|i}|it}	|i|}|	|_|S(
s/Returns the natural (base e) logarithm of self.Risln of a negative valueiii
iiN(R=RRotnegInfRjtInfRRR"RQRRYRDRFR0R+R$t_dlogRURSRXR!RR
RRR/(
RRR'RRRRtplacesRR/((s#/usr/local/lib/python2.5/decimal.pytln
s<


		-+	cCs|it|id}|djott|dSn|djottd|dSnt|}|i|i}}|djoKt|d|}td|}t|t|||jdSntd||}t|||djdS(	sCompute 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.
        iiiii
iit231(R@RUR#RSRYRDRF(RR RRRR)R*((s#/usr/local/lib/python2.5/decimal.pyRs


&c
Cs|djo
t}n|id|}|o|Sn|ptSn|idjotSn|idjo|itdSn|i	ddjoI|i	ddt
|i	djo$t|it
|i	d}nt
|}|i|i}}|i}||id}xZtoRt|||}|dd	t
tt||doPn|d
7}q%Wtt|djtt||}|i}|it}	|i|}|	|_|S(s&Returns the base 10 logarithm of self.Rislog10 of a negative valueiRRBiii
iN(R=RRoR,RjR-R"RQRR#RURR@RYRDRFR0RR$t_dlog10RSRXR!RR
RRR/(
RRR'RRRRR/RR/((s#/usr/local/lib/python2.5/decimal.pytlog10=s<

	9$	-+	cCs~|id|}|o|Sn|djo
t}n|iotSn|p|itddSnt|iS(sM 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).
        Rslogb(0)iN(	RoR=RRjR-RQRRRt(RRR'((s#/usr/local/lib/python2.5/decimal.pytlogbps	


cCsU|idjp|idjotSnx&|iD]}|djotSq2q2WtS(sReturn True if self is a logical operand.

        For being logical, it must be a finite numbers with a sign of 0,
        an exponent of 0, and a coefficient whose digits must all be
        either 0 or 1.
        it01(R"R@RVR#R$(Rtdig((s#/usr/local/lib/python2.5/decimal.pyt
_islogicals 

cCs|it|}|djod||}n |djo||i}n|it|}|djod||}n |djo||i}n||fS(NiRB(R0RU(RRtopatopbtdif((s#/usr/local/lib/python2.5/decimal.pyt
_fill_logicals



c	Cs|djo
t}n|ip|io|itSn|i||i|i\}}dig}t||D])\}}|t	t
|t
|@q~}td|idpddS(s;Applies an 'and' operation between self and other's digits.RKiRBN(
R=RR7RQRR;R#R^tzipRSRDR!RT(	RRlRR8R9t_[1]RtbR((s#/usr/local/lib/python2.5/decimal.pytlogical_ands

!OcCs=|djo
t}n|itdd|id|S(sInvert all its digits.iRN(R=Rtlogical_xorR!R0(RR((s#/usr/local/lib/python2.5/decimal.pytlogical_inverts

cCs|djo
t}n|ip|io|itSn|i||i|i\}}didt||D}t	d|i
dpddS(s:Applies an 'or' operation between self and other's digits.RKcss5x.|]'\}}tt|t|BVqWdS(N(RSRD(t.0RR>((s#/usr/local/lib/python2.5/decimal.pys	<genexpr>s	iRBN(R=RR7RQRR;R#R^R<R!RT(RRlRR8R9R((s#/usr/local/lib/python2.5/decimal.pyt
logical_ors

!"cCs|djo
t}n|ip|io|itSn|i||i|i\}}didt||D}t	d|i
dpddS(s;Applies an 'xor' operation between self and other's digits.RKcss5x.|]'\}}tt|t|AVqWdS(N(RSRD(RBRR>((s#/usr/local/lib/python2.5/decimal.pys	<genexpr>s	iRBN(R=RR7RQRR;R#R^R<R!RT(RRlRR8R9R((s#/usr/local/lib/python2.5/decimal.pyR@s

!"cCs9t|dt}|djo
t}n|ip
|io|i}|i}|p|oj|djo|djo|i|Sn|djo|djo|i|Sn|i||Sqn|ii	|i}|djo|i
|}n|djo
|}n|}|i|S(s8Compares the values numerically with their sign ignored.R|iiiN(RqR$R=RRARiRRoRRyR(RRlRRRRR'((s#/usr/local/lib/python2.5/decimal.pytmax_mags&




cCs9t|dt}|djo
t}n|ip
|io|i}|i}|p|oj|djo|djo|i|Sn|djo|djo|i|Sn|i||Sqn|ii	|i}|djo|i
|}n|djo
|}n|}|i|S(s8Compares the values numerically with their sign ignored.R|iiiN(RqR$R=RRARiRRoRRyR(RRlRRRRR'((s#/usr/local/lib/python2.5/decimal.pytmin_mags&




cCs|djo
t}n|id|}|o|Sn|idjotSn|idjo!tdd|i|iSn|i}|i	t
|i|i|}||jo|Sn|i
tdd|id|S(s=Returns the largest representable number smaller than itself.RiiiR.RN(R=RRoRjR,R!R0RR7R
Rt_ignore_all_flagsRRR(RRR'tnew_self((s#/usr/local/lib/python2.5/decimal.pyt
next_minuss"

!


cCs|djo
t}n|id|}|o|Sn|idjotSn|idjo!tdd|i|iSn|i}|i	t
|i|i|}||jo|Sn|i
tdd|id|S(s=Returns the smallest representable number larger than itself.RiiR.iRN(R=RRoRjR-R!R0RR7R
RRFRRR(RRR'RG((s#/usr/local/lib/python2.5/decimal.pyt	next_plus,s"

!


cCsTt|dt}|djo
t}n|i||}|o|Sn|i|}|djo|i|Sn|djo|i|}n|i|}|i	o4|i
td|i|i
t
|i
tng|i|ijoP|i
t|i
t|i
t
|i
t|p|i
tqPn|S(sReturns 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.
        R|iis Infinite result from next_towardN(RqR$R=RRoRyRRIRHRjRQRR"R
R	RtRR
RR(RRlRR't
comparison((s#/usr/local/lib/python2.5/decimal.pytnext_towardCs4	




	





cCs|iodSn|iodSn|i}|djodSn|djodSn|io|iodSqdSn|djo
t}n|id	|o|iod
SqdSn|iodSnd
SdS(sReturns 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
        RkR&is	+Infinityis	-Infinitys-Zeros+ZeroRs
-Subnormals
+Subnormals-Normals+NormalN(R&R$RjR(R"R=RR'(RRtinf((s#/usr/local/lib/python2.5/decimal.pytnumber_classqs,









cCs
tdS(s'Just returns 10, as this is Decimal, :)i
(R(R((s#/usr/local/lib/python2.5/decimal.pytradixscCs,|djo
t}n|i||}|o|Sn|idjo|itSn|it|jo
|ijnp|itSn|iot	|Snt|}|i
}|it|}|od||}n|||| }t|i
|idpd|iS(s5Returns a rotated copy of self, value-of-other times.iRBN(R=RRoR@RQRR0RDRjRR#RUR!R"RT(RRlRR'ttorottrotdigttopadtrotated((s#/usr/local/lib/python2.5/decimal.pytrotates&

+
		cCs|djo
t}n|i||}|o|Sn|idjo|itSnd|i|i}d|i|i}|t|jo
|jnp|itSn|i	ot
|Snt|i|i
|it|}|i|}|S(s>Returns self operand after adding the second value to its exp.iiiN(R=RRoR@RQRR1R0RDRjRR!R"R#R(RRlRR'tliminftlimsuptd((s#/usr/local/lib/python2.5/decimal.pytscalebs 

$
%cCsf|djo
t}n|i||}|o|Sn|idjo|itSn|it|jo
|ijnp|itSn|iot	|Snt|}|pt	|Sn|i
}|it|}|od||}n|djo|| }n|d|}||i}t|i
|idpd|iS(s5Returns a shifted copy of self, value-of-other times.iRBN(R=RRoR@RQRR0RDRjRR#RUR!R"RT(RRlRR'RORPRQRR((s#/usr/local/lib/python2.5/decimal.pyRs0

+
	
	cCs|it|ffS(N(t	__class__RS(R((s#/usr/local/lib/python2.5/decimal.pyt
__reduce__scCs.t|tjo|Sn|it|S(N(ttypeRRXRS(R((s#/usr/local/lib/python2.5/decimal.pyt__copy__scCs.t|tjo|Sn|it|S(N(RZRRXRS(Rtmemo((s#/usr/local/lib/python2.5/decimal.pyt__deepcopy__
s(s_exps_ints_signs_is_specialN(tRRRt	__slots__R=RMRiRjRoRpRyRzR{R}RRRRVRRRRR$RRt__radd__RRRt__rmul__Rt__truediv__RRt__rtruediv__RRRRRRRRRRR%RRRRRRRRRRRRRRRRRR
RRRtto_integralRRRRRRtRRRRRRRRFR!R"R	RR#R$R%R&R'R(R+R0RR3R4R7R;R?RARCR@RDRERHRIRKRMRNRSRWRRYR[R](((s#/usr/local/lib/python2.5/decimal.pyRs		
 		(					4
V7;	!$K					V									,T	F		"c*"					D					K									2	3		
.*	%		cCs7tit}||_||_||_||_|S(sCreate a decimal instance directly, without any validation,
    normalization (e.g. removal of leading zeros) or argument
    conversion.

    This function is for *internal use only*.
    (RLRMRR"R#R@RA(R*tcoefficientRtspecialR((s#/usr/local/lib/python2.5/decimal.pyR!
s				t_round_iR>cBs)eZdZdZdZdZRS(sContext manager class to support localcontext().

      Sets a copy of the supplied context in __enter__() and restores
      the previous decimal context in __exit__()
    cCs|i|_dS(N(R7tnew_context(RRg((s#/usr/local/lib/python2.5/decimal.pyt__init__)
scCs t|_t|i|iS(N(Rt
saved_contextRRg(R((s#/usr/local/lib/python2.5/decimal.pyt	__enter__+
s
cCst|idS(N(RRi(Rtttvttb((s#/usr/local/lib/python2.5/decimal.pyt__exit__/
s(RRRRhRjRn(((s#/usr/local/lib/python2.5/decimal.pyR>#
s		c
BseZdZdNdNdNdNdNdNdNddNd	ZdZdZdZdZeZ	dNdZ
dZd	Zd
Z
dZdZd
ZdZddZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!d Z"d!Z#d"Z$d#Z%d$Z&d%Z'd&Z(d'Z)d(Z*d)Z+d*Z,d+Z-d,Z.d-Z/d.Z0d/Z1d0Z2d1Z3d2Z4d3Z5d4Z6d5Z7d6Z8d7Z9d8Z:d9Z;d:Z<d;Z=d<Z>d=Z?d>Z@dNd?ZAd@ZBdAZCdBZDdCZEdDZFdEZGdFZHdGZIdHZJdIZKdJZLdKZMdLZNdMZOeOZPRS(OsContains 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 incremented.
             (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)
    ic
Cs=|djo
g}n|	djo
g}	nt|tp:tg}
tD]}|
|||jfqL~
}~n|dj	oKt|to:tg}tD]}||||jfq~}~nx`tiD]O\}
}|djo&t||
tit	t
|
qt||
|qW|`dS(N(R=RNtdictt_signalstlocalstitemstsetattrt_copyR7RRR(RR0R/ttrapstflagsRR1RRt_ignored_flagsR=Rt_[2]tnametval((s#/usr/local/lib/python2.5/decimal.pyRhE
s 



33
&cCsg}|idt|g}|iiD]!\}}|o||iq1q1~}|iddi|dg}|iiD]!\}}|o||iqq~}|iddi|ddi|dS(sShow the current context.saContext(prec=%(prec)d, rounding=%(rounding)s, Emin=%(Emin)d, Emax=%(Emax)d, capitals=%(capitals)dsflags=[s, t]straps=[t)(R]tvarsRvRrRR^Ru(RRR=tfRltnamesRxRk((s#/usr/local/lib/python2.5/decimal.pyR[
s	>>cCs%x|iD]}d|i|<q
WdS(sReset all flags to zeroiN(Rv(Rtflag((s#/usr/local/lib/python2.5/decimal.pyR8g
s
c
CsCt|i|i|i|i|i|i|i|i|i		}|S(s!Returns a shallow copy from self.(
RR0R/RuRvRR1RRRw(Rtnc((s#/usr/local/lib/python2.5/decimal.pyRl
sc
CsOt|i|i|ii|ii|i|i|i|i	|i
	}|S(sReturns a deep copy from self.(RR0R/RuR7RvRR1RRRw(RR((s#/usr/local/lib/python2.5/decimal.pyR7s
scGs~ti||}||ijo|i||Sn|i|cd7<|i|p|i||Sn||dS(s-Handles an error

        If the flag is in _ignored_flags, returns the default response.
        Otherwise, it increments the flag, then, if the corresponding
        trap_enabler is set, it reaises the exception.  Otherwise, it returns
        the default value after incrementing the flag.
        iN(t_condition_maptgetRwRRvRu(Rt	conditiontexplanationRterror((s#/usr/local/lib/python2.5/decimal.pyRQ{
scCs
|itS(s$Ignore all flags, if they are raised(t
_ignore_flagsRp(R((s#/usr/local/lib/python2.5/decimal.pyRF
scGs |it||_t|S(s$Ignore the flags, if they are raised(RwRZ(RRv((s#/usr/local/lib/python2.5/decimal.pyR
scGsT|o(t|dttfo|d}nx|D]}|ii|q6WdS(s+Stop ignoring the flags, if they are raisediN(RNR[RZRwtremove(RRvR((s#/usr/local/lib/python2.5/decimal.pyt
_regard_flags
s
!cCstddS(sA Context cannot be hashed.sCannot hash a Context.N(Ra(R((s#/usr/local/lib/python2.5/decimal.pyR
scCst|i|idS(s!Returns Etiny (= Emin - prec + 1)i(RDRR0(R((s#/usr/local/lib/python2.5/decimal.pyR
scCst|i|idS(s,Returns maximum exponent (= Emax - prec + 1)i(RDR1R0(R((s#/usr/local/lib/python2.5/decimal.pyR
scCs|i}||_|S(sSets 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.
        (R/(RRZR/((s#/usr/local/lib/python2.5/decimal.pyR

s		RBcCs`t|d|}|io4t|i|i|ijo|itdSn|i|S(s9Creates a new Decimal instance but using self as context.Rsdiagnostic info too long in NaN(	RRiRUR#R0RRQR(R(RR)RV((s#/usr/local/lib/python2.5/decimal.pytcreate_decimal
s
-	cCs|id|S(s"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")
        R(R(RR((s#/usr/local/lib/python2.5/decimal.pyRX
scCs|i|d|S(sReturn 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")
        R(R(RRR>((s#/usr/local/lib/python2.5/decimal.pytadd
scCst|i|S(N(RSR(RR((s#/usr/local/lib/python2.5/decimal.pyt_apply
scCs|id|S(sReturns 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")
        R(R(RR((s#/usr/local/lib/python2.5/decimal.pyR
s	cCs|i|d|S(sCompares 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")
        R(R}(RRR>((s#/usr/local/lib/python2.5/decimal.pyR}
scCs|i|d|S(sTCompares 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
        R(R(RRR>((s#/usr/local/lib/python2.5/decimal.pyRscCs
|i|S(sGCompares 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")
        (R(RRR>((s#/usr/local/lib/python2.5/decimal.pyR/scCs
|i|S(sCompares two operands using their abstract representation ignoring sign.

        Like compare_total, but with operand's sign ignored and assumed to be 0.
        (R(RRR>((s#/usr/local/lib/python2.5/decimal.pyREscCs
|iS(sReturns 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")
        (R(RR((s#/usr/local/lib/python2.5/decimal.pyRLscCs
t|S(sReturns a copy of the decimal objet.

        >>> ExtendedContext.copy_decimal(Decimal('2.1'))
        Decimal("2.1")
        >>> ExtendedContext.copy_decimal(Decimal('-1.00'))
        Decimal("-1.00")
        (R(RR((s#/usr/local/lib/python2.5/decimal.pytcopy_decimalVscCs
|iS(sReturns 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")
        (R(RR((s#/usr/local/lib/python2.5/decimal.pyR`scCs
|i|S(s>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")
        (R(RRR>((s#/usr/local/lib/python2.5/decimal.pyRjscCs|i|d|S(sDecimal 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")
        R(R(RRR>((s#/usr/local/lib/python2.5/decimal.pytdivide{scCs|i|d|S(sTDivides 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")
        R(R(RRR>((s#/usr/local/lib/python2.5/decimal.pyt
divide_ints
cCs|i|d|S(NR(R(RRR>((s#/usr/local/lib/python2.5/decimal.pyRscCs|id|S(sReturns 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")
        R(RF(RR((s#/usr/local/lib/python2.5/decimal.pyRFscCs|i||d|S(s@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")
        R(R(RRR>R((s#/usr/local/lib/python2.5/decimal.pyRscCs
|iS(sReturn 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
        (R!(RR((s#/usr/local/lib/python2.5/decimal.pyR!s	cCs
|iS(sReturn 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
        (R"(RR((s#/usr/local/lib/python2.5/decimal.pyR"scCs
|iS(sReturn 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
        (R	(RR((s#/usr/local/lib/python2.5/decimal.pyR	s
cCs
|iS(sReturn 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
        (R(RR((s#/usr/local/lib/python2.5/decimal.pyRscCs|id|S(sReturn 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
        R(R#(RR((s#/usr/local/lib/python2.5/decimal.pyR#scCs
|iS(sReturn 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
        (R$(RR((s#/usr/local/lib/python2.5/decimal.pyR$s
cCs
|iS(sReturn 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
        (R%(RR((s#/usr/local/lib/python2.5/decimal.pyR% s
cCs
|iS(sReturn 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
        (R&(RR((s#/usr/local/lib/python2.5/decimal.pyR&,scCs|id|S(sReturn 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
        R(R'(RR((s#/usr/local/lib/python2.5/decimal.pyR'9scCs
|iS(sReturn 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
        (R((RR((s#/usr/local/lib/python2.5/decimal.pyR(Ls
cCs|id|S(sReturns 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")
        R(R0(RR((s#/usr/local/lib/python2.5/decimal.pyR0XscCs|id|S(sGReturns 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")
        R(R3(RR((s#/usr/local/lib/python2.5/decimal.pyR3kscCs|id|S(s 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")
        R(R4(RR((s#/usr/local/lib/python2.5/decimal.pyR4scCs|i|d|S(sApplies 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")
        R(R?(RRR>((s#/usr/local/lib/python2.5/decimal.pyR?scCs|id|S(sInvert 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")
        R(RA(RR((s#/usr/local/lib/python2.5/decimal.pyRAscCs|i|d|S(sApplies 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")
        R(RC(RRR>((s#/usr/local/lib/python2.5/decimal.pyRCscCs|i|d|S(sApplies 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")
        R(R@(RRR>((s#/usr/local/lib/python2.5/decimal.pyR@scCs|i|d|S(smax 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 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")
        R(R(RRR>((s#/usr/local/lib/python2.5/decimal.pyRscCs|i|d|S(s8Compares the values numerically with their sign ignored.R(RD(RRR>((s#/usr/local/lib/python2.5/decimal.pyRDscCs|i|d|S(smin 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 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")
        R(R(RRR>((s#/usr/local/lib/python2.5/decimal.pyRscCs|i|d|S(s8Compares the values numerically with their sign ignored.R(RE(RRR>((s#/usr/local/lib/python2.5/decimal.pyRE
scCs|id|S(sMinus 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")
        R(R(RR((s#/usr/local/lib/python2.5/decimal.pytminusscCs|i|d|S(smultiply 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")
        R(R(RRR>((s#/usr/local/lib/python2.5/decimal.pytmultiplyscCs|id|S(sReturns 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")
        R(RH(RR((s#/usr/local/lib/python2.5/decimal.pyRH4scCs|id|S(sReturns 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")
        R(RI(RR((s#/usr/local/lib/python2.5/decimal.pyRIEscCs|i|d|S(sReturns 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")
        R(RK(RRR>((s#/usr/local/lib/python2.5/decimal.pyRKVscCs|id|S(sunormalize 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")
        R(R(RR((s#/usr/local/lib/python2.5/decimal.pyRrscCs|id|S(sReturns 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 = Context(ExtendedContext)
        >>> 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'
        R(RM(RR((s#/usr/local/lib/python2.5/decimal.pyRMs-cCs|id|S(sPlus 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")
        R(R(RR((s#/usr/local/lib/python2.5/decimal.pytplusscCs|i||d|S(s1
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")
        R(R(RRR>R((s#/usr/local/lib/python2.5/decimal.pytpowersCcCs|i|d|S(sC	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")
        R(R(RRR>((s#/usr/local/lib/python2.5/decimal.pyR	s1cCs
tdS(skJust returns 10, as this is Decimal, :)

        >>> ExtendedContext.radix()
        Decimal("10")
        i
(R(R((s#/usr/local/lib/python2.5/decimal.pyRN<scCs|i|d|S(s>Returns 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")
        R(R(RRR>((s#/usr/local/lib/python2.5/decimal.pyRDscCs|i|d|S(s`Returns 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")
        R(R(RRR>((s#/usr/local/lib/python2.5/decimal.pyR_scCs|i|d|S(s[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")
        R(RS(RRR>((s#/usr/local/lib/python2.5/decimal.pyRSzscCs
|i|S(sReturns 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
        (R
(RRR>((s#/usr/local/lib/python2.5/decimal.pyR
scCs|i|d|S(s^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")
        R(RW(RRR>((s#/usr/local/lib/python2.5/decimal.pyRWs
cCs|i|d|S(sReturns 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")
        R(R(RRR>((s#/usr/local/lib/python2.5/decimal.pyRscCs|id|S(sdSquare 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.prec
        9
        R(R(RR((s#/usr/local/lib/python2.5/decimal.pyRscCs|i|d|S(sTReturn 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")
        R(R(RRR>((s#/usr/local/lib/python2.5/decimal.pytsubtracts
cCs|id|S(syConverts a number to a string, using scientific notation.

        The operation is not affected by the context.
        R(R(RR((s#/usr/local/lib/python2.5/decimal.pyRscCs|id|S(syConverts a number to a string, using scientific notation.

        The operation is not affected by the context.
        R(R(RR((s#/usr/local/lib/python2.5/decimal.pyt
to_sci_stringscCs|id|S(skRounds 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")
        R(R(RR((s#/usr/local/lib/python2.5/decimal.pyRscCs|id|S(sLRounds 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")
        R(R(RR((s#/usr/local/lib/python2.5/decimal.pyRsN(QRRRR=RhRR8RR7R[RQRFRRRRRR
RRXRRRR}RRRRRRRRRRRFRR!R"R	RR#R$R%R&R'R(R0R3R4R?RARCR@RRDRRERRRHRIRKRRMRRRRNRRRSR
RWRRRRRRRRc(((s#/usr/local/lib/python2.5/decimal.pyR2
s														
							
	
	
										
				
																				/	E	3													RYcBs)eZdZddZdZeZRS(R*RDRFcCs|djod|_d|_d|_nft|to.|i|_t|i|_|i|_n(|d|_|d|_|d|_dS(Niii(	R=R*RDRFRNRR"R#R@(RRc((s#/usr/local/lib/python2.5/decimal.pyRh=s
		


cCsd|i|i|ifS(Ns(%r, %r, %r)(R*RDRF(R((s#/usr/local/lib/python2.5/decimal.pyRLs(ssignsintsexpN(RRR^R=RhRR(((s#/usr/local/lib/python2.5/decimal.pyRY7s	icCs|i|ijo|}|}n
|}|}tt|i}tt|i}|itd||d}||id|jod|_||_n|id|i|i9_|i|_||fS(scNormalizes op1, op2 to have the same exp and length of coefficient.

    Done during addition.
    iiii
(RFRURSRDR(RRR0ttmpRlttmp_lent	other_lenRF((s#/usr/local/lib/python2.5/decimal.pyRSs
	
iRBiRit2t3t4t5t6t7t8R.RR>RRVRR~cCsA|djotdnd|}dt|||dS(s[Number of bits in binary representation of the positive integer n,
    or 0 if n == 0.
    is-The argument to _nbits should be nonnegative.s%xi(R\RU(R t
correctionthex_n((s#/usr/local/lib/python2.5/decimal.pyRvs

cCsc|djp
|djotdnd}x,||jo||||d?}}q3W|S(sClosest 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.

    is3Both arguments to _sqrt_nearest should be positive.i(R\(R RR>((s#/usr/local/lib/python2.5/decimal.pyt
_sqrt_nearests
cCs7d|>||?}}|d||d@|d@|jS(sGiven an integer x and a nonnegative integer shift, return closest
    integer to x / 2**shift; use round-to-even in case of a tie.

    lii((RRR>R((s#/usr/local/lib/python2.5/decimal.pyt_rshift_nearestscCs/t||\}}|d||d@|jS(saClosest integer to a/b, a and b positive integers; rounds to even
    in the case of a tie.

    ii(R(RR>RR((s#/usr/local/lib/python2.5/decimal.pyt_div_nearestsic		CsH||}d}x||jo!tt|||>|jp(||jodt|||?|joItt||d>|t||t|||}|d7}qWtdtt|d|}t||}t||}x>t|dddD]&}t||t|||}q
Wt|||S(sInteger 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.iiiii(	RWRXRRRRDRURSR(	RtMtLRtRtTtyshifttwtk((s#/usr/local/lib/python2.5/decimal.pyt_ilogs
.('%$c
Cs|d7}tt|}||||dj}|djod|}|||}|djo|d|9}nt|d|}t||}t|}t|||}||}	nd}t|d|}	t|	|dS(sGiven 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.iiii
id(RURSRRt
_log10_digitstdiv_nearest(
RRRRR~RRtlog_dtlog_10tlog_tenpower((s#/usr/local/lib/python2.5/decimal.pyR2s 



c	Cs|d7}tt|}||||dj}|djoX|||}|djo|d|9}nt|d|}t|d|}nd}|o\ttt|d}||djo%t|t||d|}qd}nd}t||dS(sGiven 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.iiii
id(RURSRRRXR(	RRRRR~RRRt	f_log_ten((s#/usr/local/lib/python2.5/decimal.pyR.s"


%
t
_Log10MemoizecBs eZdZdZdZRS(sClass 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__.cCs
d|_dS(Nt/23025850929940456840179914546843642076011014886(Rg(R((s#/usr/local/lib/python2.5/decimal.pyRh$scCs|djotdn|t|ijod}xeto]d||d}tttd||d}||d|joPn|d7}q<W|idd |_nt|i|d	 S(
stGiven an integer p >= 0, return floor(10**p)*log(10).

        For example, self.getdigits(3) returns 2302.
        isp should be nonnegativeii
iidRBii(	R\RURgR$RSRRRRD(RRRRRg((s#/usr/local/lib/python2.5/decimal.pyt	getdigits's	
"(RRRRhR(((s#/usr/local/lib/python2.5/decimal.pyR s	c	Cstt||>|}tdtt|d|}t||}t||>}x9t|dddD]!}t|||||}quWxIt|dddD]1}t||d>}t||||}qW||S(sGiven 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).iiiiii(RRWRDRURSRR(	RRRRRRtMshiftRR((s#/usr/local/lib/python2.5/decimal.pyt_iexpEs%c	Cs|d7}td|tt|d}||}||}|djo|d|}n|d|}t|t|\}}t|d|}tt|d|d||dfS(sCompute 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.iiii
ii(RRURSRRRR(	RRRRRRtcshifttquotR((s#/usr/local/lib/python2.5/decimal.pyRjs
#


cCs0ttt||}t||||d}||}|djo||d|}nt||d|}|djodtt||dj|djjo!d|ddd|}	}
q&d|d|}	}
n;t||d|d\}	}
t|	d}	|
d7}
|	|
fS(s5Given 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.
    iii
(RURSRXR.RR(RRRRRR>tlxcRtpcRRF((s#/usr/local/lib/python2.5/decimal.pyRs


)!!
idiFi5i(iiii
icCsC|djotdnt|}dt|||dS(s@Compute a lower bound for 100*log10(c) for a positive integer c.is0The argument to _log10_lb should be nonnegative.id(R\RSRU(RRtstr_c((s#/usr/local/lib/python2.5/decimal.pyRs
cCs[t|to|Snt|ttfot|Sn|otd|ntS(s]Convert other to Decimal.

    Verifies that it's ok to use in an implicit construction.
    sUnable to convert %s to Decimal(RNRRDRWRaRr(RlR|((s#/usr/local/lib/python2.5/decimal.pyRqsR0iR/RuRvR1iɚ;Ri6eRi	s     # 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*)          # consisting of 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 information.
    )
#    \s*
    $
s0*$s50*$R-s-InfR&t__main__(bRt__all__R7RtRRRRRRRRtArithmeticErrorRRRR(tZeroDivisionErrorRR+R,R	R-R
RRR
RpRR9tImportErrorR4RLR2R5R;thasattrR:R6RRR=RRRVR!R=t__dict__tkeysRyt
startswithtrounding_functionstuppert
globalnametglobalsRzRR>RRYRRRRRRR2R.RRRRRRRRqRRRtretcompiletVERBOSEt
IGNORECASEtmatchRPRRR-R,R&RRRR)RtdoctestttestmodR3(((s#/usr/local/lib/python2.5/decimal.pys<module>ts	
&
		
		
.$

#$$$,				0	"	,#%	$	*-,				


Man Man