Your IP : 3.12.34.211
3
\T� � $ @ sJ d Z ddddddddd d
ddd
ddddddddddddddddddd d!d"d#d$g$ZeZd%Zd&Zd'Zd(d)lZd(d)lZ d(d)l
Z
yd(d*lmZ
e
dd+�ZW n ek
r� d,d-� ZY nX dZdZdZdZdZdZdZdZd.Ze
jd�kr�d2Zd2Zd�Znd3Zd3Zd�Zeed1 ZG d4d� de�ZG d5d� de�Z G d6d � d e�Z!G d7d� de!�Z"G d8d
� d
ee#�Z$G d9d� de!�Z%G d:d� de!e#�Z&G d;d� de�Z'G d<d� de!�Z(G d=d� de�Z)G d>d
� d
e�Z*G d?d� de'e)�Z+G d@d� de'e)e*�Z,G dAd� dee-�Z.e e$e'e+e)e,e!e*e.g Z/e"e!e%e!e&e!e(e!iZ0eeeeeeeefZ1yd(d)l2Z2W n. ek
�rh G dBdC� dCe3�Z4e4� Z2[4Y nX y
e2j5 W n> e6k
�r� e7e2j8� dD��r�e2j8� `9dEd� Z:dFd� Z;Y n6X e2j5� Z5e7e5dD��r�e5`9e5fdGd�Z;e5fdHd�Z:[2[5d�dId�Z<G dJd� de3�Z=d�dLdM�Z>e j?j@e=� G dNdO� dOe3�ZAG dPd� de3�ZBG dQdR� dRe3�ZCd�dSdT�ZDeEjFZGdUdV� ZHdWdX� ZIdYdZ� ZJd[d\� ZKd�d^d_�ZLd`da� ZMdbdc� ZNG ddde� dee3�ZOeO� jPZQd�dfdg�ZRdhdi� ZSdjdk� ZTdldmdndodpdqdrdsdtdu� fdvdw�ZUd�dxdy�ZVd�dzd{�ZWeBd|ee$e+e!gg d}d�d1d(d~�ZXeBdee$e+e!e e,gg d��ZYeBdeg g d��ZZd(d)l[Z[e[j\d�e[j]e[j^B �j_Z`e[j\d��j_Zae[j\d��j_Zbe[j\d�e[j]e[jcB �Zd[[yd(d)leZfW n ek
�r� Y nX d�d�d��Zgd�d�� Zhd�d�� Zid�d�d��Zjd�d�� Zkd�d�� Zle=d��Zme=d��Zne=d��Zoe=d(�Zpe=d1�Zqe=d��ZremenfZse
jtjuZve
jtjwZxe
jtjyZze{dsevd/ ev�Z|[
d)S )�a�
This is an implementation of decimal floating point arithmetic based on
the General Decimal Arithmetic Specification:
http://speleotrove.com/decimal/decarith.html
and IEEE standard 854-1987:
http://en.wikipedia.org/wiki/IEEE_854-1987
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 0.0; Decimal('1.00') % Decimal('0.1') returns the expected
Decimal('0.00')).
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.45e12345678')
Decimal('1.2345E+12345680')
>>> 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):
...
...
...
decimal.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):
...
...
...
decimal.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
>>>
�Decimal�Context�DecimalTuple�DefaultContext�BasicContext�ExtendedContext�DecimalException�Clamped�InvalidOperation�DivisionByZero�Inexact�Rounded� Subnormal�Overflow� Underflow�FloatOperation�DivisionImpossible�InvalidContext�ConversionSyntax�DivisionUndefined�
ROUND_DOWN�
ROUND_HALF_UP�ROUND_HALF_EVEN�
ROUND_CEILING�ROUND_FLOOR�ROUND_UP�ROUND_HALF_DOWN�
ROUND_05UP�
setcontext�
getcontext�localcontext�MAX_PREC�MAX_EMAX�MIN_EMIN� MIN_ETINY�HAVE_THREADSZdecimalz1.70z2.4.2� N)�
namedtuplezsign digits exponentc G s | S )N� )�argsr'