%PDF- %PDF-
Direktori : /lib/python3.12/__pycache__/ |
Current File : //lib/python3.12/__pycache__/_pydecimal.cpython-312.pyc |
� ���fd � � � d Z g d�ZeZdZdZdZddlZddlZ ddl Z ddlmZ e dd d� � ZdZd ZdZdZdZdZdZdZdZdZe j4 dk( rdZdZdZndZdZdZeedz z Z G d� de� Z G d� de � Z! G d� d e � Z" G d!� d"e"� Z# G d#� d$e e$� Z% G d%� d&e"� Z& G d'� d(e"e$� Z' G d)� d*e � Z( G d+� d,e"� Z) G d-� d.e � Z* G d/� d0e � Z+ G d1� d2e(e*� Z, G d3� d4e(e*e+� Z- G d5� d6e e.� Z/e!e%e(e,e*e-e"e+e/g Z0e#e"e&e"e'e"e)e"iZ1eeeeeeeefZ2ddl3Z3 e3jh d7� Z5 e6g d8�� Z7d9� Z8d:� Z9[3dtd;�Z: G d<� d=e;� Z<dud>�Z=e j| j e<� G d?� d@e;� Z@ G dA� dBe;� ZA G dC� dDe;� ZBdvdE�ZCeDj� ZFdF� ZGdG� ZHdH� ZIdI� ZJdwdJ�ZKdK� ZLdL� ZM G dM� dNe;� ZN eN� j� ZPdwdO�ZQdP� ZRdQ� ZSdRdSdTdUdVdWdXdYdZd[� fd\�ZTdxd]�ZUdud^�ZV eAd_ee%e,e"gg d`dadd�b� ZW eAdcee%e,e"e!e-gg �d� ZX eAdceg g �d� ZYddlZZZ eZj� deeZj� eZj� z � j� Z_ eZj� df� j� Z` eZj� dg� j� Za eZj� dheZj� eZj� z � Zc[Z ddldZedtdi�Zfdj� Zgdk� Zhdydl�Zidm� Zjdn� Zk e<do� Zl e<dp� Zm e<dq� Zn e<d� Zo e<d� Zp e<dr� ZqelemfZre j� j� Zue j� j� Zwe j� j� Zy ezdYeudsz eu� Z{[ y# e$ r d� ZY ��Dw xY w# e$ r Y ��w xY w)za� 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_CONTEXTVAR�decimalz1.70z2.4.2� N)� namedtupler zsign digits exponent)�modulec � � | S �N� )�argss �!/usr/lib/python3.12/_pydecimal.py�<lambda>r0 � s � �� � r r r r r r r r Tl ���� l ��N�Zol������N�Zoi@�Ti���� c � � e Zd ZdZd� Zy)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 � � y r, r- ��self�contextr. s r/ �handlezDecimalException.handle� s � �r1 N��__name__� __module__�__qualname__�__doc__r8 r- r1 r/ r r � s � ��$ r1 r c � � e Zd ZdZy)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�r: r; r<