File: //usr/lib/python3.7/__pycache__/_pydecimal.cpython-37.pyc
B
{a| $ @ s 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/krd0Zd0Zd1Znd2Zd2Zd3Zeed4 ZG d5d deZG d6d deZ G d7d d eZ!G d8d de!Z"G d9d
d
ee#Z$G d:d de!Z%G d;d de!e#Z&G d<d deZ'G d=d de!Z(G d>d deZ)G d?d
d
eZ*G d@d de'e)Z+G dAd de'e)e*Z,G dBd dee-Z.e e$e'e+e)e,e!e*e.g Z/e"e!e%e!e&e!e(e!iZ0eeeeeeeefZ1d(d)l2Z2e23dCZ4dDd Z5dEd Z6[2ddFdZ7G dGd de8Z9ddIdJZ:e j;<e9 G dKdL dLe8Z=G dMd de8Z>G dNdO dOe8Z?ddPdQZ@eAjBZCdRdS ZDdTdU ZEdVdW ZFdXdY ZGdd[d\ZHd]d^ ZId_d` ZJG dadb dbe8ZKeK jLZMddcddZNdedf ZOdgdh ZPdidjdkdldmdndodpdqdr fdsdtZQddudvZRddwdxZSe>dyee$e+e!gg dzd{d4d(d|ZTe>d}ee$e+e!e e,gg d~ZUe>d}eg g d~ZVd(d)lWZWeWXdeWjYeWjZB j[Z\eWXdj[Z]eWXdj[Z^eWXdeWjYeWj_B Z`[Wyd(d)laZbW n ek
r Y nX dddZcdd Zddd ZedddZfdd Zgdd Zhe9dZie9dZje9dZke9d(Zle9d4Zme9dZneiejfZoe
jpjqZre
jpjsZte
jpjuZvewdperd erZx[
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
>>>
DecimalContextDecimalTupleDefaultContextBasicContextExtendedContextDecimalExceptionClampedInvalidOperationDivisionByZeroInexactRounded SubnormalOverflow UnderflowFloatOperationDivisionImpossibleInvalidContextConversionSyntaxDivisionUndefined
ROUND_DOWN
ROUND_HALF_UPROUND_HALF_EVEN
ROUND_CEILINGROUND_FLOORROUND_UPROUND_HALF_DOWN
ROUND_05UP
setcontext
getcontextlocalcontextMAX_PRECMAX_EMAXMIN_EMIN MIN_ETINYHAVE_THREADSZdecimalz1.70z2.4.2 N)
namedtuplezsign digits exponentc G s | S )N )argsr' r' /usr/lib/python3.7/_pydecimal.py<lambda>