Your IP : 13.59.217.1
a
R�f:} �
@ sp d Z g d�ZeZdZdZdZddlZddlZ ddl
Z
zddlmZ
e
dd �ZW n eyh d
d� ZY n0 dZd
ZdZdZdZdZdZdZdZdZe
jdkr�dZdZdZndZdZdZeed ZG dd� de�Z G dd� de �Z!G dd � d e �Z"G d!d"� d"e"�Z#G d#d$� d$e e$�Z%G d%d&� d&e"�Z&G d'd(� d(e"e$�Z'G d)d*� d*e �Z(G d+d,� d,e"�Z)G d-d.� d.e �Z*G d/d0� d0e �Z+G d1d2� d2e(e*�Z,G d3d4� d4e(e*e+�Z-G d5d6� d6e e.�Z/e!e%e(e,e*e-e"e+e/g Z0e#e"e&e"e'e"e)e"iZ1eeeeeeeefZ2ddl3Z3e3�4d7�Z5d8d9� Z6d:d;� Z7[3d�d<d=�Z8G d>d?� d?e9�Z:d�dAdB�Z;e j<�=e:� G dCdD� dDe9�Z>G dEdF� dFe9�Z?G dGdH� dHe9�Z@d�dIdJ�ZAeBjCZDdKdL� ZEdMdN� ZFdOdP� ZGdQdR� ZHd�dTdU�ZIdVdW� ZJdXdY� ZKG dZd[� d[e9�ZLeL� jMZNd�d\d]�ZOd^d_� ZPd`da� ZQdbdcdddedfdgdhdidjdk� fdldm�ZRd�dndo�ZSd�dpdq�ZTe?dree%e,e"gg dsdtdddu�ZUe?dvee%e,e"e!e-gg dw�ZVe?dveg g dw�ZWddlXZXeX�YdxeXjZeXj[B �j\Z]eX�Ydy�j\Z^eX�Ydz�j\Z_eX�Yd{eXjZeXj`B �Za[XzddlbZcW n e�y� Y n0 d�d|d}�Zdd~d� Zed�d�� Zfd�d�d��Zgd�d�� Zhd�d�� Zie:d��Zje:d��Zke:d��Zle:d�Zme:d�Zne:d��ZoejekfZpe
jqjrZse
jqjtZue
jqjvZwexdiesd� es�Zy[
dS )�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_THREADS�HAVE_CONTEXTVARZdecimalz1.70z2.4.2� N)�
namedtupler zsign digits exponentc G s | S �N� )�argsr) r) �//opt/alt/python39/lib64/python3.9/_pydecimal.py�<lambda>� � r, r r r r r r r r Tl ���� l ��N�Zol������N�Zoi@�Ti���� c @ s e Zd ZdZdd� ZdS )r a1 Base exception class.
Used exceptions derive from this.
If an exception derives from another exception besides this (such as
Underflow (Inexact, Rounded, Subnormal) that indicates that it is only
called if the others are present. This isn't actually used for
anything, though.
handle -- Called when context._raise_error is called and the
trap_enabler is not set. First argument is self, second is the
context. More arguments can be given, those being after
the explanation in _raise_error (For example,
context._raise_error(NewError, '(-x)!', self._sign) would
call NewError().handle(context, self._sign).)
To define a new exception, it should be sufficient to have it derive
from DecimalException.
c G s d S r( r) ��self�contextr* r) r) r+ �handle� s zDecimalException.handleN��__name__�
__module__�__qualname__�__doc__r2 r) r) r) r+ r � s r c @ s e Zd ZdZdS )r a) 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").
N�r4 r5 r6 r7 r) r) r) r+ r � s r c @ s e Zd ZdZdd� ZdS )r a0 An invalid operation was performed.
Various bad things cause this:
Something creates a signaling NaN
-INF + INF
0 * (+-)INF
(+-)INF / (+-)INF
x % 0
(+-)INF % x
x._rescale( non-integer )
sqrt(-x) , x > 0
0 ** 0
x ** (non-integer)
x ** (+-)INF
An operand is invalid
The result of the operation after these is a quiet positive NaN,
except when the cause is a signaling NaN, in which case the result is
also a quiet NaN, but with the original sign, and an optional
diagnostic information.
c G s, |r(t |d j|d jdd�}|�|�S tS )Nr&