/opt/alt/python38/lib64/python3.8/__pycache__
NameSizeModeActions
abc.cpython-38.opt-1.pyc53490644editdlrm
abc.cpython-38.opt-2.pyc32270644editdlrm
abc.cpython-38.pyc53490644editdlrm
aifc.cpython-38.opt-1.pyc254890644editdlrm
aifc.cpython-38.opt-2.pyc202820644editdlrm
aifc.cpython-38.pyc254890644editdlrm
antigravity.cpython-38.opt-1.pyc8120644editdlrm
antigravity.cpython-38.opt-2.pyc6680644editdlrm
antigravity.cpython-38.pyc8120644editdlrm
argparse.cpython-38.opt-1.pyc621430644editdlrm
argparse.cpython-38.opt-2.pyc529020644editdlrm
argparse.cpython-38.pyc622920644editdlrm
ast.cpython-38.opt-1.pyc167430644editdlrm
ast.cpython-38.opt-2.pyc103480644editdlrm
ast.cpython-38.pyc167780644editdlrm
asynchat.cpython-38.opt-1.pyc68660644editdlrm
asynchat.cpython-38.opt-2.pyc54910644editdlrm
asynchat.cpython-38.pyc68660644editdlrm
asyncore.cpython-38.opt-1.pyc160430644editdlrm
asyncore.cpython-38.opt-2.pyc148390644editdlrm
asyncore.cpython-38.pyc160430644editdlrm
base64.cpython-38.opt-1.pyc169230644editdlrm
base64.cpython-38.opt-2.pyc113390644editdlrm
base64.cpython-38.pyc170860644editdlrm
bdb.cpython-38.opt-1.pyc249360644editdlrm
bdb.cpython-38.opt-2.pyc158980644editdlrm
bdb.cpython-38.pyc249360644editdlrm
binhex.cpython-38.opt-1.pyc121490644editdlrm
binhex.cpython-38.opt-2.pyc116160644editdlrm
binhex.cpython-38.pyc121490644editdlrm
bisect.cpython-38.opt-1.pyc23690644editdlrm
bisect.cpython-38.opt-2.pyc10570644editdlrm
bisect.cpython-38.pyc23690644editdlrm
bz2.cpython-38.opt-1.pyc114600644editdlrm
bz2.cpython-38.opt-2.pyc64020644editdlrm
bz2.cpython-38.pyc114600644editdlrm
calendar.cpython-38.opt-1.pyc270790644editdlrm
calendar.cpython-38.opt-2.pyc224870644editdlrm
calendar.cpython-38.pyc270790644editdlrm
cgi.cpython-38.opt-1.pyc265590644editdlrm
cgi.cpython-38.opt-2.pyc181330644editdlrm
cgi.cpython-38.pyc265590644editdlrm
cgitb.cpython-38.opt-1.pyc101650644editdlrm
cgitb.cpython-38.opt-2.pyc85660644editdlrm
cgitb.cpython-38.pyc101650644editdlrm
chunk.cpython-38.opt-1.pyc48540644editdlrm
chunk.cpython-38.opt-2.pyc27100644editdlrm
chunk.cpython-38.pyc48540644editdlrm
cmd.cpython-38.opt-1.pyc126410644editdlrm
cmd.cpython-38.opt-2.pyc72160644editdlrm
cmd.cpython-38.pyc126410644editdlrm
code.cpython-38.opt-1.pyc99280644editdlrm
code.cpython-38.opt-2.pyc46570644editdlrm
code.cpython-38.pyc99280644editdlrm
codecs.cpython-38.opt-1.pyc339710644editdlrm
codecs.cpython-38.opt-2.pyc184050644editdlrm
codecs.cpython-38.pyc339710644editdlrm
codeop.cpython-38.opt-1.pyc64320644editdlrm
codeop.cpython-38.opt-2.pyc23720644editdlrm
codeop.cpython-38.pyc64320644editdlrm
colorsys.cpython-38.opt-1.pyc32550644editdlrm
colorsys.cpython-38.opt-2.pyc26490644editdlrm
colorsys.cpython-38.pyc32550644editdlrm
compileall.cpython-38.opt-1.pyc94250644editdlrm
compileall.cpython-38.opt-2.pyc70500644editdlrm
compileall.cpython-38.pyc94250644editdlrm
configparser.cpython-38.opt-1.pyc457330644editdlrm
configparser.cpython-38.opt-2.pyc308070644editdlrm
configparser.cpython-38.pyc457330644editdlrm
contextlib.cpython-38.opt-1.pyc201910644editdlrm
contextlib.cpython-38.opt-2.pyc146110644editdlrm
contextlib.cpython-38.pyc202440644editdlrm
contextvars.cpython-38.opt-1.pyc2580644editdlrm
contextvars.cpython-38.opt-2.pyc2580644editdlrm
contextvars.cpython-38.pyc2580644editdlrm
copy.cpython-38.opt-1.pyc70020644editdlrm
copy.cpython-38.opt-2.pyc46880644editdlrm
copy.cpython-38.pyc70020644editdlrm
copyreg.cpython-38.opt-1.pyc42980644editdlrm
copyreg.cpython-38.opt-2.pyc34960644editdlrm
copyreg.cpython-38.pyc43330644editdlrm
cProfile.cpython-38.opt-1.pyc55160644editdlrm
cProfile.cpython-38.opt-2.pyc50550644editdlrm
cProfile.cpython-38.pyc55160644editdlrm
crypt.cpython-38.opt-1.pyc34020644editdlrm
crypt.cpython-38.opt-2.pyc27400644editdlrm
crypt.cpython-38.pyc34020644editdlrm
csv.cpython-38.opt-1.pyc119250644editdlrm
csv.cpython-38.opt-2.pyc98860644editdlrm
csv.cpython-38.pyc119250644editdlrm
dataclasses.cpython-38.opt-1.pyc236680644editdlrm
dataclasses.cpython-38.opt-2.pyc202280644editdlrm
dataclasses.cpython-38.pyc236680644editdlrm
datetime.cpython-38.opt-1.pyc559510644editdlrm
datetime.cpython-38.opt-2.pyc475110644editdlrm
datetime.cpython-38.pyc571880644editdlrm
decimal.cpython-38.opt-1.pyc3740644editdlrm
decimal.cpython-38.opt-2.pyc3740644editdlrm
decimal.cpython-38.pyc3740644editdlrm
difflib.cpython-38.opt-1.pyc594150644editdlrm
difflib.cpython-38.opt-2.pyc249360644editdlrm
difflib.cpython-38.pyc594530644editdlrm
dis.cpython-38.opt-1.pyc158230644editdlrm
dis.cpython-38.opt-2.pyc120160644editdlrm
dis.cpython-38.pyc158230644editdlrm
doctest.cpython-38.opt-1.pyc757460644editdlrm
doctest.cpython-38.opt-2.pyc404400644editdlrm
doctest.cpython-38.pyc759890644editdlrm
dummy_threading.cpython-38.opt-1.pyc11250644editdlrm
dummy_threading.cpython-38.opt-2.pyc7520644editdlrm
dummy_threading.cpython-38.pyc11250644editdlrm
enum.cpython-38.opt-1.pyc259770644editdlrm
enum.cpython-38.opt-2.pyc210550644editdlrm
enum.cpython-38.pyc259770644editdlrm
filecmp.cpython-38.opt-1.pyc84420644editdlrm
filecmp.cpython-38.opt-2.pyc60290644editdlrm
filecmp.cpython-38.pyc84420644editdlrm
fileinput.cpython-38.opt-1.pyc133880644editdlrm
fileinput.cpython-38.opt-2.pyc77800644editdlrm
fileinput.cpython-38.pyc133880644editdlrm
fnmatch.cpython-38.opt-1.pyc33700644editdlrm
fnmatch.cpython-38.opt-2.pyc21620644editdlrm
fnmatch.cpython-38.pyc33700644editdlrm
formatter.cpython-38.opt-1.pyc175600644editdlrm
formatter.cpython-38.opt-2.pyc151200644editdlrm
formatter.cpython-38.pyc175600644editdlrm
fractions.cpython-38.opt-1.pyc187540644editdlrm
fractions.cpython-38.opt-2.pyc113700644editdlrm
fractions.cpython-38.pyc187540644editdlrm
ftplib.cpython-38.opt-1.pyc280220644editdlrm
ftplib.cpython-38.opt-2.pyc182280644editdlrm
ftplib.cpython-38.pyc280220644editdlrm
functools.cpython-38.opt-1.pyc279160644editdlrm
functools.cpython-38.opt-2.pyc212630644editdlrm
functools.cpython-38.pyc279160644editdlrm
genericpath.cpython-38.opt-1.pyc40160644editdlrm
genericpath.cpython-38.opt-2.pyc28800644editdlrm
genericpath.cpython-38.pyc40160644editdlrm
getopt.cpython-38.opt-1.pyc62520644editdlrm
getopt.cpython-38.opt-2.pyc36980644editdlrm
getopt.cpython-38.pyc62860644editdlrm
getpass.cpython-38.opt-1.pyc41930644editdlrm
getpass.cpython-38.opt-2.pyc30080644editdlrm
getpass.cpython-38.pyc41930644editdlrm
gettext.cpython-38.opt-1.pyc178980644editdlrm
gettext.cpython-38.opt-2.pyc172070644editdlrm
gettext.cpython-38.pyc178980644editdlrm
glob.cpython-38.opt-1.pyc42930644editdlrm
glob.cpython-38.opt-2.pyc34330644editdlrm
glob.cpython-38.pyc43580644editdlrm
gzip.cpython-38.opt-1.pyc181990644editdlrm
gzip.cpython-38.opt-2.pyc143310644editdlrm
gzip.cpython-38.pyc181990644editdlrm
hashlib.cpython-38.opt-1.pyc67420644editdlrm
hashlib.cpython-38.opt-2.pyc61740644editdlrm
hashlib.cpython-38.pyc67420644editdlrm
heapq.cpython-38.opt-1.pyc140850644editdlrm
heapq.cpython-38.opt-2.pyc110690644editdlrm
heapq.cpython-38.pyc140850644editdlrm
hmac.cpython-38.opt-1.pyc64030644editdlrm
hmac.cpython-38.opt-2.pyc38860644editdlrm
hmac.cpython-38.pyc64030644editdlrm
imaplib.cpython-38.opt-1.pyc391740644editdlrm
imaplib.cpython-38.opt-2.pyc271970644editdlrm
imaplib.cpython-38.pyc413570644editdlrm
imghdr.cpython-38.opt-1.pyc41330644editdlrm
imghdr.cpython-38.opt-2.pyc38180644editdlrm
imghdr.cpython-38.pyc41330644editdlrm
imp.cpython-38.opt-1.pyc98240644editdlrm
imp.cpython-38.opt-2.pyc74590644editdlrm
imp.cpython-38.pyc98240644editdlrm
inspect.cpython-38.opt-1.pyc803230644editdlrm
inspect.cpython-38.opt-2.pyc552100644editdlrm
inspect.cpython-38.pyc806080644editdlrm
io.cpython-38.opt-1.pyc34690644editdlrm
io.cpython-38.opt-2.pyc19800644editdlrm
io.cpython-38.pyc34690644editdlrm
ipaddress.cpython-38.opt-1.pyc613510644editdlrm
ipaddress.cpython-38.opt-2.pyc367170644editdlrm
ipaddress.cpython-38.pyc613510644editdlrm
keyword.cpython-38.opt-1.pyc10130644editdlrm
keyword.cpython-38.opt-2.pyc5860644editdlrm
keyword.cpython-38.pyc10130644editdlrm
linecache.cpython-38.opt-1.pyc38820644editdlrm
linecache.cpython-38.opt-2.pyc27770644editdlrm
linecache.cpython-38.pyc38820644editdlrm
locale.cpython-38.opt-1.pyc347040644editdlrm
locale.cpython-38.opt-2.pyc300890644editdlrm
locale.cpython-38.pyc347040644editdlrm
lzma.cpython-38.opt-1.pyc120330644editdlrm
lzma.cpython-38.opt-2.pyc58640644editdlrm
lzma.cpython-38.pyc120330644editdlrm
mailbox.cpython-38.opt-1.pyc601990644editdlrm
mailbox.cpython-38.opt-2.pyc535970644editdlrm
mailbox.cpython-38.pyc602790644editdlrm
mailcap.cpython-38.opt-1.pyc72210644editdlrm
mailcap.cpython-38.opt-2.pyc56520644editdlrm
mailcap.cpython-38.pyc72210644editdlrm
mimetypes.cpython-38.opt-1.pyc160460644editdlrm
mimetypes.cpython-38.opt-2.pyc100310644editdlrm
mimetypes.cpython-38.pyc160460644editdlrm
modulefinder.cpython-38.opt-1.pyc160680644editdlrm
modulefinder.cpython-38.opt-2.pyc151590644editdlrm
modulefinder.cpython-38.pyc161300644editdlrm
netrc.cpython-38.opt-1.pyc37920644editdlrm
netrc.cpython-38.opt-2.pyc35540644editdlrm
netrc.cpython-38.pyc37920644editdlrm
nntplib.cpython-38.opt-1.pyc339890644editdlrm
nntplib.cpython-38.opt-2.pyc214790644editdlrm
nntplib.cpython-38.pyc339890644editdlrm
ntpath.cpython-38.opt-1.pyc146720644editdlrm
ntpath.cpython-38.opt-2.pyc126210644editdlrm
ntpath.cpython-38.pyc146720644editdlrm
nturl2path.cpython-38.opt-1.pyc17590644editdlrm
nturl2path.cpython-38.opt-2.pyc13400644editdlrm
nturl2path.cpython-38.pyc17590644editdlrm
numbers.cpython-38.opt-1.pyc122170644editdlrm
numbers.cpython-38.opt-2.pyc83540644editdlrm
numbers.cpython-38.pyc122170644editdlrm
opcode.cpython-38.opt-1.pyc54350644editdlrm
opcode.cpython-38.opt-2.pyc52950644editdlrm
opcode.cpython-38.pyc54350644editdlrm
operator.cpython-38.opt-1.pyc137060644editdlrm
operator.cpython-38.opt-2.pyc113370644editdlrm
operator.cpython-38.pyc137060644editdlrm
optparse.cpython-38.opt-1.pyc479890644editdlrm
optparse.cpython-38.opt-2.pyc356740644editdlrm
optparse.cpython-38.pyc480720644editdlrm
os.cpython-38.opt-1.pyc313800644editdlrm
os.cpython-38.opt-2.pyc191890644editdlrm
os.cpython-38.pyc314120644editdlrm
pathlib.cpython-38.opt-1.pyc442240644editdlrm
pathlib.cpython-38.opt-2.pyc355440644editdlrm
pathlib.cpython-38.pyc442240644editdlrm
pdb.cpython-38.opt-1.pyc471860644editdlrm
pdb.cpython-38.opt-2.pyc331150644editdlrm
pdb.cpython-38.pyc472410644editdlrm
pickle.cpython-38.opt-1.pyc468060644editdlrm
pickle.cpython-38.opt-2.pyc409340644editdlrm
pickle.cpython-38.pyc469230644editdlrm
pickletools.cpython-38.opt-1.pyc663290644editdlrm
pickletools.cpython-38.opt-2.pyc572360644editdlrm
pickletools.cpython-38.pyc672190644editdlrm
pipes.cpython-38.opt-1.pyc78100644editdlrm
pipes.cpython-38.opt-2.pyc49430644editdlrm
pipes.cpython-38.pyc78100644editdlrm
pkgutil.cpython-38.opt-1.pyc163510644editdlrm
pkgutil.cpython-38.opt-2.pyc110950644editdlrm
pkgutil.cpython-38.pyc163510644editdlrm
platform.cpython-38.opt-1.pyc243410644editdlrm
platform.cpython-38.opt-2.pyc164650644editdlrm
platform.cpython-38.pyc243410644editdlrm
plistlib.cpython-38.opt-1.pyc271130644editdlrm
plistlib.cpython-38.opt-2.pyc240640644editdlrm
plistlib.cpython-38.pyc271800644editdlrm
poplib.cpython-38.opt-1.pyc134740644editdlrm
poplib.cpython-38.opt-2.pyc85430644editdlrm
poplib.cpython-38.pyc134740644editdlrm
posixpath.cpython-38.opt-1.pyc104430644editdlrm
posixpath.cpython-38.opt-2.pyc87280644editdlrm
posixpath.cpython-38.pyc104430644editdlrm
pprint.cpython-38.opt-1.pyc162470644editdlrm
pprint.cpython-38.opt-2.pyc140920644editdlrm
pprint.cpython-38.pyc162960644editdlrm
profile.cpython-38.opt-1.pyc145810644editdlrm
profile.cpython-38.opt-2.pyc116030644editdlrm
profile.cpython-38.pyc147940644editdlrm
pstats.cpython-38.opt-1.pyc220810644editdlrm
pstats.cpython-38.opt-2.pyc195570644editdlrm
pstats.cpython-38.pyc220810644editdlrm
pty.cpython-38.opt-1.pyc39700644editdlrm
pty.cpython-38.opt-2.pyc31250644editdlrm
pty.cpython-38.pyc39700644editdlrm
pyclbr.cpython-38.opt-1.pyc104660644editdlrm
pyclbr.cpython-38.opt-2.pyc68650644editdlrm
pyclbr.cpython-38.pyc104660644editdlrm
pydoc.cpython-38.opt-1.pyc834470644editdlrm
pydoc.cpython-38.opt-2.pyc739020644editdlrm
pydoc.cpython-38.pyc835000644editdlrm
py_compile.cpython-38.opt-1.pyc73990644editdlrm
py_compile.cpython-38.opt-2.pyc36610644editdlrm
py_compile.cpython-38.pyc73990644editdlrm
queue.cpython-38.opt-1.pyc106410644editdlrm
queue.cpython-38.opt-2.pyc63040644editdlrm
queue.cpython-38.pyc106410644editdlrm
quopri.cpython-38.opt-1.pyc55880644editdlrm
quopri.cpython-38.opt-2.pyc45520644editdlrm
quopri.cpython-38.pyc57630644editdlrm
random.cpython-38.opt-1.pyc201230644editdlrm
random.cpython-38.opt-2.pyc131470644editdlrm
random.cpython-38.pyc201230644editdlrm
re.cpython-38.opt-1.pyc144370644editdlrm
re.cpython-38.opt-2.pyc60990644editdlrm
re.cpython-38.pyc144370644editdlrm
reprlib.cpython-38.opt-1.pyc53180644editdlrm
reprlib.cpython-38.opt-2.pyc51620644editdlrm
reprlib.cpython-38.pyc53180644editdlrm
rlcompleter.cpython-38.opt-1.pyc57700644editdlrm
rlcompleter.cpython-38.opt-2.pyc31070644editdlrm
rlcompleter.cpython-38.pyc57700644editdlrm
runpy.cpython-38.opt-1.pyc81960644editdlrm
runpy.cpython-38.opt-2.pyc66300644editdlrm
runpy.cpython-38.pyc81960644editdlrm
sched.cpython-38.opt-1.pyc65470644editdlrm
sched.cpython-38.opt-2.pyc35200644editdlrm
sched.cpython-38.pyc65470644editdlrm
secrets.cpython-38.opt-1.pyc22050644editdlrm
secrets.cpython-38.opt-2.pyc11470644editdlrm
secrets.cpython-38.pyc22050644editdlrm
selectors.cpython-38.opt-1.pyc169500644editdlrm
selectors.cpython-38.opt-2.pyc129150644editdlrm
selectors.cpython-38.pyc169500644editdlrm
shelve.cpython-38.opt-1.pyc95050644editdlrm
shelve.cpython-38.opt-2.pyc53540644editdlrm
shelve.cpython-38.pyc95050644editdlrm
shlex.cpython-38.opt-1.pyc75510644editdlrm
shlex.cpython-38.opt-2.pyc69940644editdlrm
shlex.cpython-38.pyc75510644editdlrm
shutil.cpython-38.opt-1.pyc374250644editdlrm
shutil.cpython-38.opt-2.pyc258870644editdlrm
shutil.cpython-38.pyc374250644editdlrm
signal.cpython-38.opt-1.pyc28580644editdlrm
signal.cpython-38.opt-2.pyc26340644editdlrm
signal.cpython-38.pyc28580644editdlrm
site.cpython-38.opt-1.pyc169920644editdlrm
site.cpython-38.opt-2.pyc114560644editdlrm
site.cpython-38.pyc169920644editdlrm
smtpd.cpython-38.opt-1.pyc264780644editdlrm
smtpd.cpython-38.opt-2.pyc238580644editdlrm
smtpd.cpython-38.pyc264780644editdlrm
smtplib.cpython-38.opt-1.pyc356250644editdlrm
smtplib.cpython-38.opt-2.pyc192630644editdlrm
smtplib.cpython-38.pyc356860644editdlrm
sndhdr.cpython-38.opt-1.pyc70040644editdlrm
sndhdr.cpython-38.opt-2.pyc57290644editdlrm
sndhdr.cpython-38.pyc70040644editdlrm
socket.cpython-38.opt-1.pyc275890644editdlrm
socket.cpython-38.opt-2.pyc196220644editdlrm
socket.cpython-38.pyc276290644editdlrm
socketserver.cpython-38.opt-1.pyc253760644editdlrm
socketserver.cpython-38.opt-2.pyc146600644editdlrm
socketserver.cpython-38.pyc253760644editdlrm
sre_compile.cpython-38.opt-1.pyc149310644editdlrm
sre_compile.cpython-38.opt-2.pyc145170644editdlrm
sre_compile.cpython-38.pyc151570644editdlrm
sre_constants.cpython-38.opt-1.pyc63740644editdlrm
sre_constants.cpython-38.opt-2.pyc59490644editdlrm
sre_constants.cpython-38.pyc63740644editdlrm
sre_parse.cpython-38.opt-1.pyc216150644editdlrm
sre_parse.cpython-38.opt-2.pyc215670644editdlrm
sre_parse.cpython-38.pyc216620644editdlrm
ssl.cpython-38.opt-1.pyc450680644editdlrm
ssl.cpython-38.opt-2.pyc340900644editdlrm
ssl.cpython-38.pyc450680644editdlrm
stat.cpython-38.opt-1.pyc43870644editdlrm
stat.cpython-38.opt-2.pyc36040644editdlrm
stat.cpython-38.pyc43870644editdlrm
statistics.cpython-38.opt-1.pyc332700644editdlrm
statistics.cpython-38.opt-2.pyc175830644editdlrm
statistics.cpython-38.pyc336680644editdlrm
string.cpython-38.opt-1.pyc73150644editdlrm
string.cpython-38.opt-2.pyc62090644editdlrm
string.cpython-38.pyc73150644editdlrm
stringprep.cpython-38.opt-1.pyc109740644editdlrm
stringprep.cpython-38.opt-2.pyc107540644editdlrm
stringprep.cpython-38.pyc110320644editdlrm
struct.cpython-38.opt-1.pyc3450644editdlrm
struct.cpython-38.opt-2.pyc3450644editdlrm
struct.cpython-38.pyc3450644editdlrm
subprocess.cpython-38.opt-1.pyc421250644editdlrm
subprocess.cpython-38.opt-2.pyc301950644editdlrm
subprocess.cpython-38.pyc422220644editdlrm
sunau.cpython-38.opt-1.pyc170950644editdlrm
sunau.cpython-38.opt-2.pyc125050644editdlrm
sunau.cpython-38.pyc170950644editdlrm
symbol.cpython-38.opt-1.pyc24190644editdlrm
symbol.cpython-38.opt-2.pyc23430644editdlrm
symbol.cpython-38.pyc24190644editdlrm
symtable.cpython-38.opt-1.pyc112430644editdlrm
symtable.cpython-38.opt-2.pyc104580644editdlrm
symtable.cpython-38.pyc113370644editdlrm
sysconfig.cpython-38.opt-1.pyc158590644editdlrm
sysconfig.cpython-38.opt-2.pyc134810644editdlrm
sysconfig.cpython-38.pyc158590644editdlrm
tabnanny.cpython-38.opt-1.pyc70450644editdlrm
tabnanny.cpython-38.opt-2.pyc61120644editdlrm
tabnanny.cpython-38.pyc70450644editdlrm
tarfile.cpython-38.opt-1.pyc700430644editdlrm
tarfile.cpython-38.opt-2.pyc554280644editdlrm
tarfile.cpython-38.pyc700740644editdlrm
telnetlib.cpython-38.opt-1.pyc182520644editdlrm
telnetlib.cpython-38.opt-2.pyc107500644editdlrm
telnetlib.cpython-38.pyc182520644editdlrm
tempfile.cpython-38.opt-1.pyc236490644editdlrm
tempfile.cpython-38.opt-2.pyc171230644editdlrm
tempfile.cpython-38.pyc236490644editdlrm
textwrap.cpython-38.opt-1.pyc134600644editdlrm
textwrap.cpython-38.opt-2.pyc62510644editdlrm
textwrap.cpython-38.pyc135340644editdlrm
this.cpython-38.opt-1.pyc12760644editdlrm
this.cpython-38.opt-2.pyc12760644editdlrm
this.cpython-38.pyc12760644editdlrm
threading.cpython-38.opt-1.pyc394400644editdlrm
threading.cpython-38.opt-2.pyc228630644editdlrm
threading.cpython-38.pyc399910644editdlrm
timeit.cpython-38.opt-1.pyc117920644editdlrm
timeit.cpython-38.opt-2.pyc59380644editdlrm
timeit.cpython-38.pyc117920644editdlrm
token.cpython-38.opt-1.pyc25000644editdlrm
token.cpython-38.opt-2.pyc24670644editdlrm
token.cpython-38.pyc25000644editdlrm
tokenize.cpython-38.opt-1.pyc171310644editdlrm
tokenize.cpython-38.opt-2.pyc133670644editdlrm
tokenize.cpython-38.pyc171750644editdlrm
trace.cpython-38.opt-1.pyc200610644editdlrm
trace.cpython-38.opt-2.pyc170470644editdlrm
trace.cpython-38.pyc200610644editdlrm
traceback.cpython-38.opt-1.pyc199530644editdlrm
traceback.cpython-38.opt-2.pyc110500644editdlrm
traceback.cpython-38.pyc199530644editdlrm
tracemalloc.cpython-38.opt-1.pyc173780644editdlrm
tracemalloc.cpython-38.opt-2.pyc159650644editdlrm
tracemalloc.cpython-38.pyc173780644editdlrm
tty.cpython-38.opt-1.pyc10910644editdlrm
tty.cpython-38.opt-2.pyc9820644editdlrm
tty.cpython-38.pyc10910644editdlrm
types.cpython-38.opt-1.pyc91920644editdlrm
types.cpython-38.opt-2.pyc79700644editdlrm
types.cpython-38.pyc91920644editdlrm
typing.cpython-38.opt-1.pyc623860644editdlrm
typing.cpython-38.opt-2.pyc456380644editdlrm
typing.cpython-38.pyc624350644editdlrm
uu.cpython-38.opt-1.pyc38010644editdlrm
uu.cpython-38.opt-2.pyc35570644editdlrm
uu.cpython-38.pyc38010644editdlrm
uuid.cpython-38.opt-1.pyc235640644editdlrm
uuid.cpython-38.opt-2.pyc164080644editdlrm
uuid.cpython-38.pyc236980644editdlrm
warnings.cpython-38.opt-1.pyc132070644editdlrm
warnings.cpython-38.opt-2.pyc109320644editdlrm
warnings.cpython-38.pyc136670644editdlrm
wave.cpython-38.opt-1.pyc181140644editdlrm
wave.cpython-38.opt-2.pyc121220644editdlrm
wave.cpython-38.pyc181640644editdlrm
weakref.cpython-38.opt-1.pyc195030644editdlrm
weakref.cpython-38.opt-2.pyc162190644editdlrm
weakref.cpython-38.pyc195330644editdlrm
webbrowser.cpython-38.opt-1.pyc171020644editdlrm
webbrowser.cpython-38.opt-2.pyc146920644editdlrm
webbrowser.cpython-38.pyc171350644editdlrm
xdrlib.cpython-38.opt-1.pyc82360644editdlrm
xdrlib.cpython-38.opt-2.pyc77510644editdlrm
xdrlib.cpython-38.pyc82360644editdlrm
zipapp.cpython-38.opt-1.pyc58690644editdlrm
zipapp.cpython-38.opt-2.pyc46930644editdlrm
zipapp.cpython-38.pyc58690644editdlrm
zipfile.cpython-38.opt-1.pyc589970644editdlrm
zipfile.cpython-38.opt-2.pyc501780644editdlrm
zipfile.cpython-38.pyc590340644editdlrm
zipimport.cpython-38.opt-1.pyc171860644editdlrm
zipimport.cpython-38.opt-2.pyc136680644editdlrm
zipimport.cpython-38.pyc172900644editdlrm
_bootlocale.cpython-38.opt-1.pyc12320644editdlrm
_bootlocale.cpython-38.opt-2.pyc10070644editdlrm
_bootlocale.cpython-38.pyc12580644editdlrm
_collections_abc.cpython-38.opt-1.pyc287560644editdlrm
_collections_abc.cpython-38.opt-2.pyc236970644editdlrm
_collections_abc.cpython-38.pyc287560644editdlrm
_compat_pickle.cpython-38.opt-1.pyc54580644editdlrm
_compat_pickle.cpython-38.opt-2.pyc54580644editdlrm
_compat_pickle.cpython-38.pyc55160644editdlrm
_compression.cpython-38.opt-1.pyc41610644editdlrm
_compression.cpython-38.opt-2.pyc39470644editdlrm
_compression.cpython-38.pyc41610644editdlrm
_dummy_thread.cpython-38.opt-1.pyc60520644editdlrm
_dummy_thread.cpython-38.opt-2.pyc34070644editdlrm
_dummy_thread.cpython-38.pyc60520644editdlrm
_markupbase.cpython-38.opt-1.pyc76330644editdlrm
_markupbase.cpython-38.opt-2.pyc72550644editdlrm
_markupbase.cpython-38.pyc78050644editdlrm
_osx_support.cpython-38.opt-1.pyc116080644editdlrm
_osx_support.cpython-38.opt-2.pyc89170644editdlrm
_osx_support.cpython-38.pyc116080644editdlrm
_pydecimal.cpython-38.opt-1.pyc1607500644editdlrm
_pydecimal.cpython-38.opt-2.pyc791330644editdlrm
_pydecimal.cpython-38.pyc1607500644editdlrm
_pyio.cpython-38.opt-1.pyc740740644editdlrm
_pyio.cpython-38.opt-2.pyc511810644editdlrm
_pyio.cpython-38.pyc740940644editdlrm
_py_abc.cpython-38.opt-1.pyc46470644editdlrm
_py_abc.cpython-38.opt-2.pyc34340644editdlrm
_py_abc.cpython-38.pyc46850644editdlrm
_sitebuiltins.cpython-38.opt-1.pyc34960644editdlrm
_sitebuiltins.cpython-38.opt-2.pyc29720644editdlrm
_sitebuiltins.cpython-38.pyc34960644editdlrm
_strptime.cpython-38.opt-1.pyc160590644editdlrm
_strptime.cpython-38.opt-2.pyc123310644editdlrm
_strptime.cpython-38.pyc160590644editdlrm
_sysconfigdata_d_linux_x86_64-linux-gnu.cpython-38.opt-1.pyc296270644editdlrm
_sysconfigdata_d_linux_x86_64-linux-gnu.cpython-38.opt-2.pyc296270644editdlrm
_sysconfigdata_d_linux_x86_64-linux-gnu.cpython-38.pyc296270644editdlrm
_sysconfigdata__linux_x86_64-linux-gnu.cpython-38.opt-1.pyc297650644editdlrm
_sysconfigdata__linux_x86_64-linux-gnu.cpython-38.opt-2.pyc297650644editdlrm
_sysconfigdata__linux_x86_64-linux-gnu.cpython-38.pyc297650644editdlrm
_threading_local.cpython-38.opt-1.pyc64610644editdlrm
_threading_local.cpython-38.opt-2.pyc31410644editdlrm
_threading_local.cpython-38.pyc64610644editdlrm
_weakrefset.cpython-38.opt-1.pyc76150644editdlrm
_weakrefset.cpython-38.opt-2.pyc76150644editdlrm
_weakrefset.cpython-38.pyc76150644editdlrm
__future__.cpython-38.opt-1.pyc41730644editdlrm
__future__.cpython-38.opt-2.pyc22010644editdlrm
__future__.cpython-38.pyc41730644editdlrm
__phello__.foo.cpython-38.opt-1.pyc1420644editdlrm
__phello__.foo.cpython-38.opt-2.pyc1420644editdlrm
__phello__.foo.cpython-38.pyc1420644editdlrm
Edit: /opt/alt/python38/lib64/python3.8/__pycache__/_pydecimal.cpython-38.opt-1.pyc (160750B)
U if:}%@sdZddddddddd d d d d ddddddddddddddddddd d!d"d#d$d%g%ZeZd&Zd'Zd(Zd)d*lZd)d*lZ d)d*l Z zd)d+l m Z e dd,ZWnek rd-d.ZYnXdZdZdZdZdZdZdZdZd/Zd/Ze jd0krd1Zd1Zd2Zn d3Zd3Zd4Zeed5ZGd6ddeZ Gd7dde Z!Gd8d d e Z"Gd9dde"Z#Gd:d d e e$Z%Gd;dde"Z&Gddde"Z)Gd?d d e Z*Gd@d d e Z+GdAdde(e*Z,GdBdde(e*e+Z-GdCdde e.Z/e!e%e(e,e*e-e"e+e/g Z0e#e"e&e"e'e"e)e"iZ1eeeeeeeefZ2d)d*l3Z3e34dDZ5dEdZ6dFdZ7[3ddGdZ8GdHdde9Z:ddJdKZ;e j<=e:GdLdMdMe9Z>GdNdde9Z?GdOdPdPe9Z@ddQdRZAeBjCZDdSdTZEdUdVZFdWdXZGdYdZZHdd\d]ZId^d_ZJd`daZKGdbdcdce9ZLeLjMZNddddeZOdfdgZPdhdiZQdjdkdldmdndodpdqdrds fdtduZRddvdwZSddxdyZTe?dzee%e,e"ggd{d|d5d)d}ZUe?d~ee%e,e"e!e-ggdZVe?d~eggdZWd)d*lXZXeXYdeXjZeXj[Bj\Z]eXYdj\Z^eXYdj\Z_eXYdeXjZeXj`BZa[Xz d)d*lbZcWnek rYnXdddZdddZeddZfdddZgddZhddZie:dZje:dZke:dZle:d)Zme:d5Zne:dZoejekfZpe jqjrZse jqjtZue jqjvZwexdqesdesZy[ 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 >>> DecimalContext DecimalTupleDefaultContext BasicContextExtendedContextDecimalExceptionClampedInvalidOperationDivisionByZeroInexactRounded SubnormalOverflow UnderflowFloatOperationDivisionImpossibleInvalidContextConversionSyntaxDivisionUndefined ROUND_DOWN ROUND_HALF_UPROUND_HALF_EVEN ROUND_CEILING ROUND_FLOORROUND_UPROUND_HALF_DOWN ROUND_05UP setcontext getcontext localcontextMAX_PRECMAX_EMAXMIN_EMIN MIN_ETINY HAVE_THREADSHAVE_CONTEXTVARdecimalz1.70z2.4.2N) namedtuplezsign digits exponentcGs|SN)argsr*r*//opt/alt/python38/lib64/python3.8/_pydecimal.pyr-TllNZolNZoi@Tic@seZdZdZddZdS)ra1Base 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. cGsdSr)r*selfcontextr+r*r*r,handleszDecimalException.handleN__name__ __module__ __qualname____doc__r3r*r*r*r,rsc@seZdZdZdS)ra)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"). Nr5r6r7r8r*r*r*r,rsc@seZdZdZddZdS)r a0An 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,|r(t|dj|djdd}||StS)Nr'nT)_dec_from_triple_sign_int_fix_nan_NaN)r1r2r+ansr*r*r,r3s zInvalidOperation.handleNr4r*r*r*r,r sc@seZdZdZddZdS)rzTrying to convert badly formed string. This occurs and signals invalid-operation if a string is being converted to a number and it does not conform to the numeric string syntax. The result is [0,qNaN]. cGstSr)r?r0r*r*r,r3szConversionSyntax.handleNr4r*r*r*r,rsc@seZdZdZddZdS)r aDivision 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|Sr))_SignedInfinityr1r2signr+r*r*r,r3szDivisionByZero.handleNr4r*r*r*r,r s c@seZdZdZddZdS)rzCannot 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]. cGstSr)rAr0r*r*r,r3"szDivisionImpossible.handleNr4r*r*r*r,rsc@seZdZdZddZdS)rzUndefined 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]. cGstSr)rAr0r*r*r,r3-szDivisionUndefined.handleNr4r*r*r*r,r%sc@seZdZdZdS)r aHad 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. Nr9r*r*r*r,r 0sc@seZdZdZddZdS)raInvalid 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]. cGstSr)rAr0r*r*r,r3GszInvalidContext.handleNr4r*r*r*r,r<s c@seZdZdZdS)r aNumber 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. Nr9r*r*r*r,r Jsc@seZdZdZdS)r aExponent < 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. Nr9r*r*r*r,r Vsc@seZdZdZddZdS)raNumerical 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|jttttfkrt|S|dkrR|jtkr4t|St|d|j|j |jdS|dkr|jt krlt|St|d|j|j |jdSdS)Nr'9r/) roundingrrrrrBrr;precEmaxrrCr*r*r,r3ws"    zOverflow.handleNr4r*r*r*r,rasc@seZdZdZdS)raxNumerical 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. Nr9r*r*r*r,rsc@seZdZdZdS)raEnable stricter semantics for mixing floats and Decimals. If the signal is not trapped (default), mixing floats and Decimals is permitted in the Decimal() constructor, context.create_decimal() and all comparison operators. Both conversion and comparisons are exact. Any occurrence of a mixed operation is silently recorded by setting FloatOperation in the context flags. Explicit conversions with Decimal.from_float() or context.create_decimal_from_float() do not set the flag. Otherwise (the signal is trapped), only equality comparisons and explicit conversions are silent. All other mixed operations raise FloatOperation. Nr9r*r*r*r,rsZdecimal_contextcCs8z tWStk r2t}t||YSXdS)zReturns 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)_current_context_varget LookupErrorrsetr2r*r*r,rs   cCs,|tttfkr|}|t|dS)z%Set this thread's context to context.N)rrrcopy clear_flagsrIrLrMr*r*r,rscCs|dkrt}t|S)abReturn 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 >>> setcontext(DefaultContext) >>> print(getcontext().prec) 28 >>> with localcontext(): ... ctx = getcontext() ... ctx.prec += 2 ... print(ctx.prec) ... 30 >>> with localcontext(ExtendedContext): ... print(getcontext().prec) ... 9 >>> print(getcontext().prec) 28 N)r_ContextManager)Zctxr*r*r,rs$c @seZdZdZdZdddZeddZd d Zd d Z dd dZ ddZ ddZ ddZ dddZdddZdddZdddZdddZddd Zd!d"Zd#d$Zd%d&Zd'd(Zdd*d+Zdd,d-Zdd.d/Zdd0d1Zdd3d4Zdd5d6ZeZdd7d8Zdd9d:Z dd;d<Z!e!Z"dd=d>Z#d?d@Z$ddAdBZ%ddCdDZ&ddEdFZ'ddGdHZ(ddIdJZ)d dKdLZ*d dMdNZ+d dOdPZ,dQdRZ-dSdTZ.e.Z/e0dUdVZ1e0dWdXZ2dYdZZ3d[d\Z4d]d^Z5d_d`Z6dadbZ7dcddZ8dedfZ9dgdhZ:didjZ;dkdlZe?e7e8e9e:e;edqZ@d drdsZAdtduZBdvdwZCd dxdyZDddzd{ZEd|d}ZFdd~dZGdddZHdddZIdddZJdddZKddZLddZMdddZNdddZOeOZPdddZQdddZRdddZSddZTddZUddZVddZWdddZXdddZYdddZZddZ[ddZ\dddZ]dddZ^ddZ_ddZ`ddZaddZbdddZcddZdddZeddZfdddZgddZhddZid ddÄZjddńZkd!ddDŽZld"ddɄZmdd˄Zndd̈́Zod#ddτZpd$ddфZqd%ddӄZrd&ddՄZsd'ddׄZtd(ddلZud)ddۄZvd*dd݄Zwd+dd߄Zxd,ddZyddZzd-ddZ{d.ddZ|d/ddZ}ddZ~ddZddZd0ddZdS(1rz,Floating point class for decimal arithmetic.)_expr=r< _is_special0Nc Cst|}t|tr$t|dd}|dkrP|dkr@t}|t d|S| ddkrfd|_ nd|_ | d }|dk r| d pd}t | d pd }tt |||_ |t||_d |_nZ| d}|dk rtt |pd d |_ | drd|_nd|_n d |_ d|_d|_|St|t rf|dkrBd|_ nd|_ d|_tt||_ d |_|St|tr|j|_|j |_ |j |_ |j|_|St|tr|j|_ t|j |_ t |j|_d |_|St|ttfr"t|dkrtdt|dt r|ddkstd|d|_ |ddkrHd |_ |d|_d|_ng} |dD]R} t| t rd| kr|dkrnn| s| dkr| | ntdqT|ddkrdtt| |_ |d|_d|_nDt|dt rdtt| pdg|_ |d|_d |_ntd|St|trx|dkr>t}|tdt|}|j|_|j |_ |j |_ |j|_|St d|dS)aCreate 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 Decimal('314') >>> Decimal(Decimal(314)) # another decimal instance Decimal('314') >>> Decimal(' 3.14 \n') # leading and trailing whitespace okay Decimal('3.14') _NzInvalid literal for Decimal: %rrD-r/r'intZfracexprSFdiagsignalNr:FTztInvalid tuple size in creation of Decimal from list or tuple. The list or tuple should have exactly three elements.r'r/z|Invalid sign. The first value in the tuple should be an integer; either 0 for a positive number or 1 for a negative number. zTThe second value in the tuple must be composed of integers in the range 0 through 9.r:r[zUThe third value in the tuple must be an integer, or one of the strings 'F', 'n', 'N'.;strict semantics for mixing floats and Decimals are enabledzCannot convert %r to Decimal)!object__new__ isinstancestr_parserstripreplacer _raise_errorrgroupr<rWr=lenrQrRlstripabsr_WorkReprDrXlisttuple ValueErrorappendjoinmapfloatr from_float TypeError) clsvaluer2r1mintpartfracpartrXrYdigitsdigitr*r*r,rd s               (       zDecimal.__new__cCst|tr,|dkrdnd}d}tt|}nzt|trt|sJt|rV|t|St d|dkrld}nd}t| \}}| d}t|d|}nt dt ||| }|tkr|S||SdS)a.Converts a float to a decimal number, exactly. Note that Decimal.from_float(0.1) is not the same as Decimal('0.1'). Since 0.1 is not exactly representable in binary floating point, the value is stored as the nearest representable value which is 0x1.999999999999ap-4. The exact equivalent of the value in decimal is 0.1000000000000000055511151231257827021181583404541015625. >>> Decimal.from_float(0.1) Decimal('0.1000000000000000055511151231257827021181583404541015625') >>> Decimal.from_float(float('nan')) Decimal('NaN') >>> Decimal.from_float(float('inf')) Decimal('Infinity') >>> Decimal.from_float(-float('inf')) Decimal('-Infinity') >>> Decimal.from_float(-0.0) Decimal('-0') r'r/g?zargument must be int or float.N)rerWrfrnrv_mathZisinfZisnanreprZcopysignas_integer_ratio bit_lengthrxr;r)ryfrDkcoeffr:dresultr*r*r,rws$    zDecimal.from_floatcCs(|jr$|j}|dkrdS|dkr$dSdS)zrReturns whether the number is not actually one. 0 if a number 1 if NaN 2 if sNaN r:r/r[r_r')rRrQ)r1rXr*r*r,_isnanszDecimal._isnancCs|jdkr|jrdSdSdS)zyReturns whether the number is infinite 0 if finite or not a number 1 if +INF -1 if -INF r\r/r')rQr<r1r*r*r, _isinfinitys  zDecimal._isinfinitycCs||}|dkrd}n|}|s&|rx|dkr4t}|dkrJ|td|S|dkr`|td|S|rn||S||SdS)zReturns 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. NFr_sNaNr')rrrjr r>)r1otherr2 self_is_nan other_is_nanr*r*r, _check_nanss&   zDecimal._check_nanscCsv|dkrt}|js|jrr|r0|td|S|rF|td|S|r\|td|S|rr|td|SdS)aCVersion of _check_nans used for the signaling comparisons compare_signal, __le__, __lt__, __ge__, __gt__. Signal InvalidOperation if either self or other is a (quiet or signaling) NaN. Signaling NaNs take precedence over quiet NaNs. Return 0 if neither operand is a NaN. Nzcomparison involving sNaNzcomparison involving NaNr')rrRis_snanrjr is_qnanr1rr2r*r*r,_compare_check_nans s0  zDecimal._compare_check_nanscCs|jp|jdkS)zuReturn True if self is nonzero; otherwise return False. NaNs and infinities are considered nonzero. rSrRr=rr*r*r,__bool__*szDecimal.__bool__cCs|js |jr8|}|}||kr(dS||kr4dSdS|sP|sDdSd|j S|s^d|jS|j|jkrndS|j|jkr~dS|}|}||kr|jd|j|j}|jd|j|j}||krdS||krd|j Sd|jSn ||krd|jSd|j SdS)zCompare the two non-NaN decimal instances self and other. Returns -1 if self < other, 0 if self == other and 1 if self > other. This routine is for internal use only.r'rr/rSN)rRrr<adjustedr=rQ)r1rZself_infZ other_inf self_adjustedZother_adjusted self_paddedZ other_paddedr*r*r,_cmp1s>         z Decimal._cmpcCs<t||dd\}}|tkr|S|||r.dS||dkS)NT) equality_opFr')_convert_for_comparisonNotImplementedrrrr*r*r,__eq__qs  zDecimal.__eq__cCs<t||\}}|tkr|S|||}|r.dS||dkSNFr'rrrrr1rr2r@r*r*r,__lt__ys zDecimal.__lt__cCs<t||\}}|tkr|S|||}|r.dS||dkSrrrr*r*r,__le__s zDecimal.__le__cCs<t||\}}|tkr|S|||}|r.dS||dkSrrrr*r*r,__gt__s zDecimal.__gt__cCs<t||\}}|tkr|S|||}|r.dS||dkSrrrr*r*r,__ge__s zDecimal.__ge__cCs>t|dd}|js|r0|jr0|||}|r0|St||S)zCompare self to other. Return a decimal value: a or b is a NaN ==> Decimal('NaN') a < b ==> Decimal('-1') a == b ==> Decimal('0') a > b ==> Decimal('1') Traiseit)_convert_otherrRrrrrr*r*r,compares   zDecimal.comparecCs|jr4|rtdn|r$tS|jr0t StS|jdkrNtd|jt }ntt |j t }t |j |t }|dkr||n| }|dkrdS|S)zx.__hash__() <==> hash(x)z"Cannot hash a signaling NaN value.r' r) rRrrxis_nan _PyHASH_NANr< _PyHASH_INFrQpow_PyHASH_MODULUS _PyHASH_10INVrWr=)r1Zexp_hashZhash_r@r*r*r,__hash__s  zDecimal.__hash__cCst|jttt|j|jS)zeRepresents the number as a triple tuple. To show the internals exactly as they are. )rr<rqrurWr=rQrr*r*r,as_tupleszDecimal.as_tuplecCs|jr |rtdntd|s(dSt|j}|jdkrR|d|jd}}nn|j }|dkr|ddkr|d}|d8}qZ|j }t|| @d|}|r||L}||8}d||>}|j r| }||fS)aExpress a finite Decimal instance in the form n / d. Returns a pair (n, d) of integers. When called on an infinity or NaN, raises OverflowError or ValueError respectively. >>> Decimal('3.14').as_integer_ratio() (157, 50) >>> Decimal('-123e5').as_integer_ratio() (-12300000, 1) >>> Decimal('0.00').as_integer_ratio() (0, 1) z#cannot convert NaN to integer ratioz(cannot convert Infinity to integer ratior^r'rr/r) rRrrr OverflowErrorrWr=rQminrr<)r1r:rZd5Zd2Zshift2r*r*r,rs,     zDecimal.as_integer_ratiocCs dt|S)z0Represents the number as an instance of Decimal.z Decimal('%s'))rfrr*r*r,__repr__szDecimal.__repr__Fc Csbddg|j}|jrL|jdkr&|dS|jdkr>|d|jS|d|jS|jt|j}|jdkrt|d krt|}n6|s~d }n,|jd kr|d d d }n|d d d }|dkrd }d d | |j}nL|t|jkr|jd |t|j}d}n |jd|}d |j|d}||kr(d}n*|dkr8t}ddg|jd||}||||S)zReturn string representation of the number in scientific notation. Captures all of the information in the underlying representation. rUrVr\ZInfinityr:NaNrr'r/rSr].NeEz%+d)r<rRrQr=rlrcapitals) r1engr2rD leftdigitsdotplacer|r}rXr*r*r,__str__s:     zDecimal.__str__cCs|jd|dS)a,Convert to a string, using engineering notation if an exponent is needed. Engineering notation has an exponent which is a multiple of 3. This can leave up to 3 digits to the left of the decimal place and may require the addition of either one or two trailing zeros. T)rr2)rr1r2r*r*r, to_eng_string;szDecimal.to_eng_stringcCsR|jr|j|d}|r|S|dkr(t}|s@|jtkr@|}n|}||S)zRReturns a copy with the sign switched. Rounds, if it has reason. rMN)rRrrrFrcopy_abs copy_negate_fixr1r2r@r*r*r,__neg__Ds  zDecimal.__neg__cCsR|jr|j|d}|r|S|dkr(t}|s@|jtkr@|}nt|}||S)zhReturns a copy, unless it is a sNaN. Rounds the number (if more than precision digits) rMN)rRrrrFrrrrrr*r*r,__pos__Zs  zDecimal.__pos__TcCsJ|s |S|jr&|j|d}|r&|S|jr:|j|d}n |j|d}|S)zReturns 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(). rM)rrRrr<rr)r1roundr2r@r*r*r,__abs__os  zDecimal.__abs__c Csht|}|tkr|S|dkr"t}|js.|jr|||}|rB|S|rr|j|jkrj|rj|tdSt |S|rt |St |j |j }d}|j t kr|j|jkrd}|s|st |j|j}|rd}t|d|}||}|S|st||j |jd}|||j }||}|S|sVt||j |jd}|||j }||}|St|}t|}t|||j\}}t} |j|jkr|j|jkrt|d|}||}|S|j|jkr||}}|jdkrd| _|j|j|_|_nd| _n&|jdkrd| _d\|_|_nd| _|jdkr<|j|j| _n|j|j| _|j| _t | }||}|S)zbReturns self + other. -INF + INF (or the reverse) cause InvalidOperation errors. Nz -INF + INFr'r/rS)r'r')rrrrRrrr<rjr rrrQrFrr;rmaxrG_rescalero _normalizerDrWrX) r1rr2r@rXZ negativezerorDop1op2rr*r*r,__add__s|              zDecimal.__add__cCsHt|}|tkr|S|js |jr6|j||d}|r6|S|j||dS)zReturn self - otherrM)rrrRrrrrr*r*r,__sub__s zDecimal.__sub__cCs"t|}|tkr|S|j||dS)zReturn other - selfrM)rrrrr*r*r,__rsub__szDecimal.__rsub__cCs@t|}|tkr|S|dkr"t}|j|jA}|js:|jr|||}|rN|S|rn|sf|tdSt |S|r|s|tdSt |S|j |j }|r|st |d|}| |}|S|j dkrt ||j |}| |}|S|j dkr t ||j |}| |}|St|}t|}t |t|j|j|}| |}|S)z\Return self * other. (+-) INF * 0 (or its reverse) raise InvalidOperation. Nz (+-)INF * 0z 0 * (+-)INFrS1)rrrr<rRrrrjr rBrQr;rr=rorfrW)r1rr2Z resultsignr@Z resultexprrr*r*r,__mul__sH             zDecimal.__mul__c Cst|}|tkrtS|dkr"t}|j|jA}|js:|jr|||}|rN|S|rj|rj|tdS|rzt |S|r|t dt |d| S|s|s|t dS|td|S|s|j|j}d}nt|jt|j|jd}|j|j|}t|}t|} |dkr:t|jd || j\}} nt|j| jd | \}} | rt|d dkr|d7}n8|j|j} || kr|d dkr|d }|d7}qt |t||}||S) zReturn self / other.Nz(+-)INF/(+-)INFzDivision by infinityrSz0 / 0zx / 0r'r/rr)rrrr<rRrrrjr rBrr;Etinyrr rQrlr=rGrodivmodrWrfr) r1rr2rDr@rXrshiftrr remainder ideal_expr*r*r, __truediv__,sP           zDecimal.__truediv__c Cs|j|jA}|r|j}nt|j|j}||}|rN|sN|dkrht|dd|||jfS||jkr t |}t |}|j |j kr|j d|j |j 9_ n|j d|j |j 9_ t |j |j \}} |d|jkr t|t |dt|jt | |fS|td} | | fS)zReturn (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. rrSr'rz%quotient too large in //, % or divmod)r<rrQrrr;rrFrGrorXrWrrfrjr) r1rr2rDrexpdiffrrqrr@r*r*r,_dividegs0     zDecimal._dividecCs"t|}|tkr|S|j||dS)z)Swaps self/other and returns __truediv__.rM)rrrrr*r*r, __rtruediv__szDecimal.__rtruediv__cCst|}|tkr|S|dkr"t}|||}|r:||fS|j|jA}|r~|rj|td}||fSt||tdfS|s|s|t d}||fS|t d||tdfS| ||\}}| |}||fS)z6 Return (self // other, self % other) Nzdivmod(INF, INF)INF % xz divmod(0, 0)x // 0x % 0) rrrrr<rrjr rBrr rr)r1rr2r@rDZquotientrr*r*r, __divmod__s4        zDecimal.__divmod__cCs"t|}|tkr|S|j||dS)z(Swaps self/other and returns __divmod__.rM)rrrrr*r*r, __rdivmod__szDecimal.__rdivmod__cCst|}|tkr|S|dkr"t}|||}|r6|S|rJ|tdS|sj|r^|tdS|tdS|||d}| |}|S)z self % other Nrrz0 % 0r/) rrrrrrjr rrr)r1rr2r@rr*r*r,__mod__s"     zDecimal.__mod__cCs"t|}|tkr|S|j||dS)z%Swaps self/other and returns __mod__.rM)rrrrr*r*r,__rmod__szDecimal.__rmod__c Cs|dkrt}t|dd}|||}|r.|S|rB|tdS|sb|rV|tdS|tdS|r|t|}||St |j |j }|st |j d|}||S| | }||jdkr|tS|d kr|||j}||St|}t|}|j|jkr(|jd |j|j9_n|jd |j|j9_t|j|j\}} d | |d@|jkr~| |j8} |d7}|d |jkr|tS|j } | d krd| } | } t | t| |}||S) zI Remainder nearest to 0- abs(remainder-near) <= other/2 NTrzremainder_near(infinity, x)zremainder_near(x, 0)zremainder_near(0, 0)rSr/rrr_r')rrrrrjr rrrrrQr;r<rrGrrrFrorXrWrrf) r1rr2r@ideal_exponentrrrrrrDr*r*r,remainder_nears`         zDecimal.remainder_nearcCst|}|tkr|S|dkr"t}|||}|r6|S|rb|rR|tdSt|j|jAS|s|r|t d|j|jAS|t dS| ||dS)z self // otherNz INF // INFrz0 // 0r') rrrrrrjr rBr<r rrrr*r*r, __floordiv__'s&    zDecimal.__floordiv__cCs"t|}|tkr|S|j||dS)z*Swaps self/other and returns __floordiv__.rM)rrrrr*r*r, __rfloordiv__CszDecimal.__rfloordiv__cCs8|r(|rtd|jr"dnd}nt|}t|S)zFloat representation.z%Cannot convert signaling NaN to floatz-nannan)rrrrr<rfrvr1sr*r*r, __float__Js zDecimal.__float__cCst|jr(|rtdn|r(tdd|j}|jdkrT|t|jd|jS|t|jd|jpjdSdS)z1Converts self to an int, truncating if necessary.zCannot convert NaN to integerz"Cannot convert infinity to integerrr'rNrS) rRrrrrrr<rQrWr=rr*r*r,__int__Ts   zDecimal.__int__cCs|Sr)r*rr*r*r,realcsz Decimal.realcCstdS)Nr'rrr*r*r,imaggsz Decimal.imagcCs|Sr)r*rr*r*r, conjugatekszDecimal.conjugatecCs tt|Sr))complexrvrr*r*r, __complex__nszDecimal.__complex__cCsR|j}|j|j}t||krJ|t||dd}t|j||jdSt|S)z2Decapitate the payload of a NaN to fit the contextNrST) r=rGclamprlrmr;r<rQr)r1r2ZpayloadZmax_payload_lenr*r*r,r>qs   zDecimal._fix_nancCsX|jr |r||St|S|}|}|s|j|g|j}tt |j ||}||j krx| t t |jd|St|St|j|j |j}||kr| td|j}| t| t|S||k}|r|}|j |krt|j|j |} | dkrt |jd|d}d} |j|j} | || } |jd| p>d} | dkr~tt| d} t| |jkr~| dd} |d7}||kr| td|j}nt |j| |}| r|r| t|r| t| r| t| t|s| t |S|r | t|jdkrP|j |krP| t |jd|j |} t |j| |St|S)zRound 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. rS above Emaxr'rr/Nr)rRrr>rrEtoprHrrrrQrjrr;r<rlr=rGrr r _pick_rounding_functionrFrfrWrr )r1r2rrexp_maxZnew_expZexp_minr@Zself_is_subnormalr~Zrounding_methodchangedrrr*r*r,r}sn                     z Decimal._fixcCst|j|rdSdSdS)z(Also known as round-towards-0, truncate.r'rN) _all_zerosr=r1rGr*r*r, _round_downs zDecimal._round_downcCs || S)zRounds away from 0.)rrr*r*r, _round_upszDecimal._round_upcCs*|j|dkrdSt|j|r"dSdSdS)zRounds 5 up (away from 0)Z56789r/r'rN)r=rrr*r*r,_round_half_ups  zDecimal._round_half_upcCst|j|rdS||SdS)z Round 5 downrN _exact_halfr=rrr*r*r,_round_half_downs zDecimal._round_half_downcCs8t|j|r*|dks&|j|ddkr*dS||SdS)z!Round 5 to even, rest to nearest.r'r/02468rNrrr*r*r,_round_half_evens zDecimal._round_half_evencCs |jr||S|| SdS)z(Rounds up (not away from 0 if negative.)Nr<rrr*r*r,_round_ceilings zDecimal._round_ceilingcCs |js||S|| SdS)z'Rounds down (not towards 0 if negative)Nrrr*r*r, _round_floor s zDecimal._round_floorcCs0|r |j|ddkr ||S|| SdS)z)Round down unless digit prec-1 is 0 or 5.r/Z05N)r=rrr*r*r, _round_05ups zDecimal._round_05up)rrrrrrrrcCsb|dk r2t|tstdtdd| }||S|jrR|rJtdntdt| dt S)aRound self to the nearest integer, or to a given precision. If only one argument is supplied, round a finite Decimal instance self to the nearest integer. If self is infinite or a NaN then a Python exception is raised. If self is finite and lies exactly halfway between two integers then it is rounded to the integer with even last digit. >>> round(Decimal('123.456')) 123 >>> round(Decimal('-456.789')) -457 >>> round(Decimal('-3.0')) -3 >>> round(Decimal('2.5')) 2 >>> round(Decimal('3.5')) 4 >>> round(Decimal('Inf')) Traceback (most recent call last): ... OverflowError: cannot round an infinity >>> round(Decimal('NaN')) Traceback (most recent call last): ... ValueError: cannot round a NaN If a second argument n is supplied, self is rounded to n decimal places using the rounding mode for the current context. For an integer n, round(self, -n) is exactly equivalent to self.quantize(Decimal('1En')). >>> round(Decimal('123.456'), 0) Decimal('123') >>> round(Decimal('123.456'), 2) Decimal('123.46') >>> round(Decimal('123.456'), -2) Decimal('1E+2') >>> round(Decimal('-Infinity'), 37) Decimal('NaN') >>> round(Decimal('sNaN123'), 0) Decimal('NaN123') Nz+Second argument to round should be integralr'rcannot round a NaNcannot round an infinity) rerWrxr;quantizerRrrrrrr)r1r:rXr*r*r, __round__&s/   zDecimal.__round__cCs0|jr |rtdntdt|dtS)zReturn the floor of self, as an integer. For a finite Decimal instance self, return the greatest integer n such that n <= self. If self is infinite or a NaN then a Python exception is raised. r r r')rRrrrrrWrrrr*r*r, __floor__ds  zDecimal.__floor__cCs0|jr |rtdntdt|dtS)zReturn the ceiling of self, as an integer. For a finite Decimal instance self, return the least integer n such that n >= self. If self is infinite or a NaN then a Python exception is raised. r r r')rRrrrrrWrrrr*r*r,__ceil__ss  zDecimal.__ceil__cCst|dd}t|dd}|js$|jr|dkr2t}|jdkrJ|td|S|jdkrb|td|S|jdkrr|}nf|jdkr|}nV|jdkr|s|tdSt|j|jA}n*|jdkr|s|td St|j|jA}n0t|j|jAt t |j t |j |j|j}| ||S) a: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. TrNr[rr:r\zINF * 0 in fmaz0 * INF in fma) rrRrrQrjr rBr<r;rfrWr=r)r1rZthirdr2productr*r*r,fmas<           z Decimal.fmac Cst|}|tkr|St|}|tkr(|S|dkr6t}|}|}|}|sZ|sZ|r|dkrp|td|S|dkr|td|S|dkr|td|S|r||S|r||S||S|r|r|s|tdS|dkr|tdS|s |tdS||j kr(|tdS|s@|s@|td S| rPd}n|j }t t |}t|}t|} |j |td |j||}t| jD]} t|d |}qt|| j |}t|t|dS) z!Three argument version of __pow__Nr_rz@pow() 3rd argument not allowed unless all arguments are integersr'zApow() 2nd argument cannot be negative when 3rd argument specifiedzpow() 3rd argument cannot be 0zSinsufficient precision: pow() 3rd argument must not have more than precision digitszXat least one of pow() 1st argument and 2nd argument must be nonzero; 0**0 is not definedr)rrrrrjr r> _isintegerrrG_isevenr<rnrWroto_integral_valuerrXranger;rf) r1rmodulor2rrZ modulo_is_nanrDbaseexponentir*r*r, _power_modulos         zDecimal._power_modulocCst|}|j|j}}|ddkr4|d}|d7}qt|}|j|j}}|ddkrh|d}|d7}qJ|dkr||9}|ddkr|d}|d7}qz|dkrdS|d|} |jdkr| } |r|jdkr|jt|} t| | |d} nd} tddd| | | S|jdkr|d} | dkr|| @|krBdSt |d} |dd }|t t |krpdSt | ||} t |||}| dks|dkrdS| |krdSd | }n| d krt |d d } t d | |\}}|rdS|d dkr|d }| d8} q|dd }|t t |kr6dSt | ||} t |||}| dksf|dkrjdS| |krxdSd | }ndS|d|krdS| |}tdt ||S|dkr|d|d}}n|dkrt t t||| krdSt |}|dkr,t t t||| kr,dS|d| }}|d |d kr\dkrtnn|d }|d }q<|d |d krdkrnn|d }|d }qt|dkrX|dkr||krdSt ||\}}|dkrdSdt | | >}t |||d\}}||kr$q|S|sPt|jddS|j|g|j }t |j }|j }|j |ddkr||kr|d7}|d8}qtt|j|j d||S)z?Normalize- strip trailing 0s, change anything equal to 0 to 0e0NrMrSr'r/) rrRrrrr;r<rHrrrlr=rQ)r1r2r@duprendrXr*r*r, normalize s$    zDecimal.normalizecCst|dd}|dkrt}|dkr(|j}|js4|jr||||}|rH|S|sX|r||rp|rpt|S|tdS| |j kr|j ksn|tdS|st |j d|j }||S|}||j kr|tdS||j d|jkr|td S||j |}||j kr.|tdSt|j|jkrL|td S|rl||jkrl|t|j |j kr||kr|t|t||}|S) zQuantize self so its exponent is the same as that of exp. Similar to self._rescale(exp._exp) but with error checking. TrNzquantize with one INFz)target exponent out of bounds in quantizerSz9exponent of quantize result too large for current contextr/z7quantize result has too many digits for current context)rrrFrRrrrrjr rrQrHr;r<rrrGrrlr=Eminr r r )r1rXrFr2r@rr*r*r,r s`          zDecimal.quantizecCsDt|dd}|js|jr8|r(|p6|o6|S|j|jkS)a=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. Tr)rrRr is_infiniterQrr*r*r, same_quantum% s  zDecimal.same_quantumcCs|jrt|S|s t|jd|S|j|krHt|j|jd|j||St|j|j|}|dkrzt|jd|d}d}|j|}|||}|jd|pd}|dkrtt |d}t|j||S)asRescale 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 rSr'rr/N) rRrr;r<rQr=rlrrfrW)r1rXrFr~Z this_functionrrr*r*r,r4 s&    zDecimal._rescalecCsf|dkrtd|js|s"t|S||d||}||krb||d||}|S)a"Round a nonzero, nonspecial Decimal to a fixed number of significant figures, using the given rounding mode. Infinities, NaNs and zeros are returned unaltered. This operation is quiet: it raises no flags, and uses no information from the context. r'z'argument should be at least 1 in _roundr/)rrrRrrr)r1placesrFr@r*r*r,_roundV s  zDecimal._roundcCs|jr"|j|d}|r|St|S|jdkr4t|S|sFt|jddS|dkrTt}|dkrb|j}|d|}||kr| t | t |S)aVRounds 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. rMr'rSN) rRrrrQr;r<rrFrrjr r r1rFr2r@r*r*r,to_integral_exactm s$      zDecimal.to_integral_exactcCs`|dkrt}|dkr|j}|jr>|j|d}|r6|St|S|jdkrPt|S|d|SdS)z@Rounds to the nearest integer, without raising inexact, rounded.NrMr')rrFrRrrrQrrCr*r*r,r s  zDecimal.to_integral_valuecCs|dkrt}|jrB|j|d}|r(|S|rB|jdkrBt|S|sdt|jd|jd}||S|jdkrz| t dS|j d}t |}|j d?}|j d@r|jd}t|jd?d}n|j}t|jdd?}||}|dkr|d |9}d } nt|d | \}} | } ||8}d|} || } | | kr:qJn | | d?} q"| oZ| | |k} | r|dkrz| d|} n| d| 9} ||7}n| d dkr| d7} tdt| |}|}|t} ||}| |_|S) zReturn the square root of self.NrMr'rSr_r/zsqrt(-x), x > 0rr#Tr)rrRrrr<rr;rQrrjr rGrorXrWrlr=rrf _shallow_copy _set_roundingrrF)r1r2r@rGoprclrr7rr:rrFr*r*r,sqrt s^              z Decimal.sqrtcCst|dd}|dkrt}|js&|jr~|}|}|s>|r~|dkrX|dkrX||S|dkrr|dkrr||S|||S||}|dkr||}|dkr|}n|}||S)zReturns the larger value. Like max(self, other) except if one is not a number, returns NaN (and signals if one is sNaN). Also rounds. TrNr/r'rrrrRrrrr compare_totalr1rr2ZsnZonrHr@r*r*r,r s&       z Decimal.maxcCst|dd}|dkrt}|js&|jr~|}|}|s>|r~|dkrX|dkrX||S|dkrr|dkrr||S|||S||}|dkr||}|dkr|}n|}||S)zReturns the smaller value. Like min(self, other) except if one is not a number, returns NaN (and signals if one is sNaN). Also rounds. TrNr/r'rrKrMr*r*r,r* s&       z Decimal.mincCs8|jr dS|jdkrdS|j|jd}|dt|kS)z"Returns whether self is an integerFr'TNrS)rRrQr=rl)r1restr*r*r,rL s  zDecimal._isintegercCs&|r|jdkrdS|jd|jdkS)z:Returns True if self is even. Assumes self is an integer.r'Trr)rQr=rr*r*r,rU szDecimal._isevencCs2z|jt|jdWStk r,YdSXdS)z$Return the adjusted exponent of selfr/r'N)rQrlr=rxrr*r*r,r[ szDecimal.adjustedcCs|S)zReturns the same Decimal object. As we do not have different encodings for the same number, the received object already is in its canonical form. r*rr*r*r, canonicalc szDecimal.canonicalcCs.t|dd}|||}|r |S|j||dS)zCompares self to the other operand numerically. It's pretty much like compare(), but all NaNs signal, with signaling NaNs taking precedence over quiet NaNs. TrrM)rrrrr*r*r,compare_signalk s   zDecimal.compare_signalcCs`t|dd}|jr|jstS|js,|jr,tS|j}|}|}|sL|r||krt|j|jf}t|j|jf}||kr|rtStS||kr|rtStStS|r|dkrtS|dkrtS|dkrtS|dkrtSn2|dkrtS|dkrtS|dkrtS|dkrtS||krtS||kr$tS|j|jkr@|rReturn True if self is a qNaN or sNaN; otherwise return False.rarZrr*r*r,r; szDecimal.is_nancCs*|js |sdS|dkrt}|j|kS)z?Return True if self is a normal number; otherwise return False.FN)rRrr>rrr*r*r, is_normal? s  zDecimal.is_normalcCs |jdkS)z;Return True if self is a quiet NaN; otherwise return False.r:rZrr*r*r,rG szDecimal.is_qnancCs |jdkS)z8Return True if self is negative; otherwise return False.r/)r<rr*r*r, is_signedK szDecimal.is_signedcCs |jdkS)z?Return True if self is a signaling NaN; otherwise return False.r[rZrr*r*r,rO szDecimal.is_snancCs*|js |sdS|dkrt}||jkS)z9Return True if self is subnormal; otherwise return False.FN)rRrrr>rr*r*r, is_subnormalS s  zDecimal.is_subnormalcCs|j o|jdkS)z6Return True if self is a zero; otherwise return False.rSrrr*r*r,is_zero[ szDecimal.is_zerocCs|jt|jd}|dkr4tt|dddS|dkrXttd|dddSt|}|j|j}}|dkrt|d| }t|}t|t|||kS|ttd| |dS)zCompute 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. r/rrrr'rQrlr=rfrorWrXr1rWrGrHrnumZdenr*r*r, _ln_exp_bound_ szDecimal._ln_exp_boundc Cs|dkrt}|j|d}|r"|S|s*tS|dkr:tS|tkrFtS|jdkr\|t dSt |}|j |j }}|j }||d}t|||}|ddttt||drq|d7}qtt |d ktt|| }|}|t} ||}| |_|S) z/Returns the natural (base e) logarithm of self.NrMr/zln of a negative valuer_rrr]r')rr_NegativeInfinityr _Infinityr1rRr<rjr rorWrXrGrc_dlogrlrfrnr;rErFrrrF r1r2r@rGrHrr'rArrFr*r*r,lnx s:    $   z Decimal.lncCs|jt|jd}|dkr,tt|dS|dkrHttd|dSt|}|j|j}}|dkrt|d| }td|}t|t|||kdStd| |}t|||dkdS) zCompute 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. r/rrr'rr_Z231r`rar*r*r,r2 s  zDecimal._log10_exp_boundc CsF|dkrt}|j|d}|r"|S|s*tS|dkr:tS|jdkrP|tdS|jddkr|jdddt |jdkrt |j t |jd}nt |}|j |j}}|j}||d}t|||}|d d t tt||drq|d 7}qtt |dktt|| }|}|t} ||}| |_|S) z&Returns the base 10 logarithm of self.NrMr/zlog10 of a negative valuer'rrSr_rrr])rrrdrrer<rjr r=rlrrQrorWrXrGr2_dlog10rfrnr;rErFrrrFrgr*r*r,log10 s:   . $   z Decimal.log10cCsV|j|d}|r|S|dkr"t}|r.tS|s@|tddSt|}||S)aM 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). rMNzlogb(0)r/) rrrrerjr rrrrr*r*r,logb s  z Decimal.logbcCs6|jdks|jdkrdS|jD]}|dkrdSqdS)zReturn True if self is a logical operand. For being logical, it must be a finite number with a sign of 0, an exponent of 0, and a coefficient whose digits must all be either 0 or 1. r'FZ01T)r<rQr=)r1digr*r*r, _islogical s  zDecimal._islogicalcCs|jt|}|dkr$d||}n|dkr<||j d}|jt|}|dkr`d||}n|dkrx||j d}||fS)Nr'rS)rGrl)r1r2opaopbZdifr*r*r, _fill_logical' szDecimal._fill_logicalcCsz|dkrt}t|dd}|r*|s4|tS|||j|j\}}dddt||D}t d| dptddS) z;Applies an 'and' operation between self and other's digits.NTrrUcSs$g|]\}}tt|t|@qSr*rfrW.0r/br*r*r, B sz'Decimal.logical_and..r'rS rrrnrjr rqr=rtzipr;rmr1rr2rorprr*r*r, logical_and4 s  zDecimal.logical_andcCs(|dkrt}|tdd|jd|S)zInvert all its digits.Nr'r)r logical_xorr;rGrr*r*r,logical_invertE s zDecimal.logical_invertcCsz|dkrt}t|dd}|r*|s4|tS|||j|j\}}dddt||D}t d| dptddS) z:Applies an 'or' operation between self and other's digits.NTrrUcSs$g|]\}}tt|t|BqSr*rrrsr*r*r,rvZ sz&Decimal.logical_or..r'rSrwryr*r*r, logical_orL s  zDecimal.logical_orcCsz|dkrt}t|dd}|r*|s4|tS|||j|j\}}dddt||D}t d| dptddS) z;Applies an 'xor' operation between self and other's digits.NTrrUcSs$g|]\}}tt|t|AqSr*rrrsr*r*r,rvk sz'Decimal.logical_xor..r'rSrwryr*r*r,r{] s  zDecimal.logical_xorcCst|dd}|dkrt}|js&|jr~|}|}|s>|r~|dkrX|dkrX||S|dkrr|dkrr||S|||S||}|dkr||}|dkr|}n|}||Sz8Compares the values numerically with their sign ignored.TrNr/r'r rrrRrrrrrrLrMr*r*r,max_magn s&      zDecimal.max_magcCst|dd}|dkrt}|js&|jr~|}|}|s>|r~|dkrX|dkrX||S|dkrr|dkrr||S|||S||}|dkr||}|dkr|}n|}||Sr~rrMr*r*r,min_mag s&      zDecimal.min_magcCs|dkrt}|j|d}|r"|S|dkr2tS|dkrTtdd|j|S|}|t | | |}||kr|S| tdd| d|S)z=Returns the largest representable number smaller than itself.NrMrr/r'rEr)rrrrdr;rGrrNrFr_ignore_all_flagsrrrr1r2r@Znew_selfr*r*r, next_minus s$     zDecimal.next_minuscCs|dkrt}|j|d}|r"|S|dkr2tS|dkrTtdd|j|S|}|t | | |}||kr|S| tdd| d|S)z=Returns the smallest representable number larger than itself.NrMr/rrEr'r)rrrrer;rGrrNrFrrrrrrr*r*r, next_plus s$     zDecimal.next_pluscCst|dd}|dkrt}|||}|r.|S||}|dkrJ||S|dkr^||}n ||}|r|t d|j |t |t nD| |jkr|t|t|t |t |s|t|S)aReturns 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. TrNr'rz Infinite result from next_toward)rrrrrUrrrrjrr<r r rr>rr r)r1rr2r@Z comparisonr*r*r, next_toward s6             zDecimal.next_towardcCs|r dS|rdS|}|dkr,dS|dkr8dS|rN|jrJdSdS|d kr\t}|j|d rv|jrrd Sd S|jrd SdSd S)aReturns 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 rrr/z +Infinityrz -Infinityz-Zeroz+ZeroNrMz -Subnormalz +Subnormalz-Normalz+Normal)rrrr^r<rr])r1r2infr*r*r, number_classs, zDecimal.number_classcCstdS)z'Just returns 10, as this is Decimal, :)rrrr*r*r,radix0sz Decimal.radixcCs|dkrt}t|dd}|||}|r.|S|jdkrB|tS|j t|kr`|jksln|tS|r|t |St|}|j }|jt |}|dkrd||}n|dkr|| d}||d|d|}t |j |dpd|jS)z5Returns a rotated copy of self, value-of-other times.NTrr'rSrrrrQrjr rGrWrrr=rlr;r<rm)r1rr2r@torotrotdigtopadZrotatedr*r*r,rotate4s0       zDecimal.rotatecCs|dkrt}t|dd}|||}|r.|S|jdkrB|tSd|j|j}d|j|j}|t|krz|ksn|tS| rt |St |j |j |jt|}||}|S)z>Returns self operand after adding the second value to its exp.NTrr'rr_)rrrrQrjr rHrGrWrrr;r<r=r)r1rr2r@ZliminfZlimsuprr*r*r,scalebUs"      zDecimal.scalebcCs|dkrt}t|dd}|||}|r.|S|jdkrB|tS|j t|kr`|jksln|tS|r|t |St|}|j }|jt |}|dkrd||}n|dkr|| d}|dkr|d|}n|d|}||j d}t |j |dp d|jS)z5Returns a shifted copy of self, value-of-other times.NTrr'rSr)r1rr2r@rrrZshiftedr*r*r,rns6       z Decimal.shiftcCs|jt|ffSr)) __class__rfrr*r*r, __reduce__szDecimal.__reduce__cCst|tkr|S|t|Sr)typerrrfrr*r*r,__copy__s zDecimal.__copy__cCst|tkr|S|t|Sr)r)r1Zmemor*r*r, __deepcopy__s zDecimal.__deepcopy__cCsJ|dkrt}t||d}|jrXt|j|}t|}|ddkrL|d7}t|||S|ddkrvddg|j|d<|ddkrt |j|j |j d}|j }|d}|dk r|dd kr| |d |}nF|dd kr|| |}n*|dd krt|j |kr| ||}|s@|j d kr@|dd kr@|d |}|j t|j } |dd kr~|sx|dk rxd |} nd } nB|dd kr| } n.|dd kr|j d kr| dkr| } nd } | d krd} d| |j } nP| t|j kr|j d| t|j } d} n"|j d| p d} |j | d} | | } t|j| | | |S)a|Format a Decimal instance according to the given specifier. The specifier should be a standard format specifier, with the form described in PEP 3101. Formatting types 'e', 'E', 'f', 'F', 'g', 'G', 'n' and '%' are supported. If the formatting type is omitted it defaults to 'g' or 'G', depending on the value of context.capitals. N) _localeconvr%gGr_ precisioneEr/zfF%ZgGr'rrSrU)r_parse_format_specifierrR _format_signr<rfr _format_alignrr;r=rQrFrBrrl_format_number)r1Z specifierr2rspecrDbodyrFrrrr|r}rXr*r*r, __format__sZ               zDecimal.__format__)rSN)NN)N)N)N)N)N)N)FN)N)N)N)TN)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)NN)N)N)NN)N)NN)NN)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)NN)r5r6r7r8 __slots__rd classmethodrwrrrrrrrrrrrrrrrrrrrrrr__radd__rrr__rmul__rrrrrrrrrrrr __trunc__propertyrrrrr>rrrrrrr r r dictrrrrrrr0r9r:r=rr@rrBrDr to_integralrJrrrrrrOrPrLrTrrrUrXrXrYr?rr[rr\rr]r^rcrhr2rkrlrnrqrzr|r}r{rrrrrrrrrrrrrrr*r*r*r,rs  , !@  2 4    V   7 ;!  $    K       f  > , Un Y   = "   c * "  I   K   2 3          . * !  'FcCs&tt}||_||_||_||_|S)zCreate a decimal instance directly, without any validation, normalization (e.g. removal of leading zeros) or argument conversion. This function is for *internal use only*. )rcrdrr<r=rQrR)rDZ coefficientrZspecialr1r*r*r,r;s  r;c@s(eZdZdZddZddZddZdS) rPzContext manager class to support localcontext(). Sets a copy of the supplied context in __enter__() and restores the previous decimal context in __exit__() cCs||_dSr))rN new_context)r1rr*r*r,__init__sz_ContextManager.__init__cCst|_t|j|jSr))r saved_contextrrrr*r*r, __enter__s z_ContextManager.__enter__cCst|jdSr))rr)r1tvtbr*r*r,__exit__sz_ContextManager.__exit__N)r5r6r7r8rrrr*r*r*r,rPsrPc @seZdZdZdddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZeZdddZddZddZdd ZdZd!d"Zd#d$Zd%d&Zdd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7Zd8d9Z d:d;Z!dd?Z#d@dAZ$dBdCZ%dDdEZ&dFdGZ'dHdIZ(dJdKZ)dLdMZ*dNdOZ+dPdQZ,dRdSZ-dTdUZ.dVdWZ/dXdYZ0dZd[Z1d\d]Z2d^d_Z3d`daZ4dbdcZ5dddeZ6dfdgZ7dhdiZ8djdkZ9dldmZ:dndoZ;dpdqZdvdwZ?dxdyZ@dzd{ZAd|d}ZBd~dZCddZDddZEddZFddZGdddZHddZIddZJddZKddZLddZMddZNddZOddZPddZQddZRddZSddZTddZUddZVeVZWdS)raContains 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 set. (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) Nc s>zt} Wntk rYnX|dk r*|n| j|_|dk r>|n| j|_|dk rR|n| j|_|dk rf|n| j|_|dk rz|n| j|_|dk r|n| j|_| dkrg|_n| |_dkr| j |_ n.t t st fddt D|_ n|_ dkr t t d|_n0t t s4t fddt D|_n|_dS)Nc3s|]}|t|kfVqdSr)rWrtrr5r*r, Isz#Context.__init__..r'c3s|]}|t|kfVqdSr)rrr6r*r,rPs)r NameErrorrGrFr>rHrr_ignored_flagsr5rNrerr4fromkeysr6) r1rGrFr>rHrrr6r5rZdcr*)r6r5r,r0s.   zContext.__init__cCst|tstd||dkr<||krtd||||fnJ|dkrb||krtd||||fn$||ksr||krtd||||ft|||S)Nz%s must be an integer-infz%s must be in [%s, %d]. got: %srz%s must be in [%d, %s]. got: %sz%s must be in [%d, %d]. got %s)rerWrxrrrc __setattr__)r1namerzZvminZvmaxr*r*r,_set_integer_checkTs  zContext._set_integer_checkcCs`t|tstd||D]}|tkrtd|qtD]}||kr8td|q8t|||S)Nz%s must be a signal dictz%s is not a valid signal dict)rerrxr4KeyErrorrcr)r1rrkeyr*r*r,_set_signal_dictbs  zContext._set_signal_dictcCs|dkr|||ddS|dkr0|||ddS|dkrH|||ddS|dkr`|||ddS|d krx|||ddS|d kr|tkrtd |t|||S|d ks|d kr|||S|dkrt|||Std|dS)NrGr/rr>rr'rHrrrFz%s: invalid rounding moder6r5rz.'decimal.Context' object has no attribute '%s')r_rounding_modesrxrcrrAttributeError)r1rrzr*r*r,rms*  zContext.__setattr__cCstd|dS)Nz%s cannot be deleted)r)r1rr*r*r, __delattr__szContext.__delattr__c CsNdd|jD}dd|jD}|j|j|j|j|j|j|j ||ffS)NcSsg|]\}}|r|qSr*r*rtZsigrr*r*r,rvsz&Context.__reduce__..cSsg|]\}}|r|qSr*r*rr*r*r,rvs) r6itemsr5rrGrFr>rHrr)r1r6r5r*r*r,rszContext.__reduce__cCs|g}|dt|dd|jD}|dd|ddd|jD}|dd|dd|d S) zShow the current context.zrContext(prec=%(prec)d, rounding=%(rounding)s, Emin=%(Emin)d, Emax=%(Emax)d, capitals=%(capitals)d, clamp=%(clamp)dcSsg|]\}}|r|jqSr*r5)rtrrr*r*r,rvsz$Context.__repr__..zflags=[z, ]cSsg|]\}}|r|jqSr*r)rtrrr*r*r,rvsztraps=[))rsvarsr6rrtr5)r1rnamesr*r*r,rszContext.__repr__cCs|jD]}d|j|<qdS)zReset all flags to zeror'Nrr1flagr*r*r,rOs zContext.clear_flagscCs|jD]}d|j|<qdS)zReset all traps to zeror'Nrrr*r*r, clear_trapss zContext.clear_trapsc Cs.t|j|j|j|j|j|j|j|j|j }|S)z!Returns a shallow copy from self.) rrGrFr>rHrrr6r5rr1Zncr*r*r,rEszContext._shallow_copyc Cs6t|j|j|j|j|j|j|j|j |j }|S)zReturns a deep copy from self.) rrGrFr>rHrrr6rNr5rrr*r*r,rNsz Context.copycGsZt||}||jkr(|j|f|Sd|j|<|j|sN|j|f|S||dS)a#Handles an error If the flag is in _ignored_flags, returns the default response. Otherwise, it sets the flag, then, if the corresponding trap_enabler is set, it reraises the exception. Otherwise, it returns the default value after setting the flag. r/N)_condition_maprJrr3r6r5)r1Z conditionZ explanationr+errorr*r*r,rjs    zContext._raise_errorcCs |jtS)z$Ignore all flags, if they are raised) _ignore_flagsr4rr*r*r,rszContext._ignore_all_flagscGs|jt||_t|S)z$Ignore the flags, if they are raised)rrp)r1r6r*r*r,rszContext._ignore_flagscGs8|rt|dttfr|d}|D]}|j|q"dS)z+Stop ignoring the flags, if they are raisedr'N)rerqrprremove)r1r6rr*r*r, _regard_flagsszContext._regard_flagscCst|j|jdS)z!Returns Etiny (= Emin - prec + 1)r/)rWr>rGrr*r*r,rsz Context.EtinycCst|j|jdS)z,Returns maximum exponent (= Emax - prec + 1)r/)rWrHrGrr*r*r,rsz Context.EtopcCs|j}||_|S)aSets 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. )rF)r1rrFr*r*r,rFszContext._set_roundingrScCsjt|tr*||ksd|kr*|tdSt||d}|r`t|j|j |j kr`|tdS| |S)zCreates a new Decimal instance but using self as context. This method implements the to-number operation of the IBM Decimal specification.rTzAtrailing or leading whitespace and underscores are not permitted.rMzdiagnostic info too long in NaN) rerfrhrjrrrrlr=rGrr)r1rbrr*r*r,create_decimals zContext.create_decimalcCst|}||S)aCreates a new Decimal instance from a float but rounding using self as the context. >>> context = Context(prec=5, rounding=ROUND_DOWN) >>> context.create_decimal_from_float(3.1415926535897932) Decimal('3.1415') >>> context = Context(prec=5, traps=[Inexact]) >>> context.create_decimal_from_float(3.1415926535897932) Traceback (most recent call last): ... decimal.Inexact: None )rrwr)r1rrr*r*r,create_decimal_from_floats z!Context.create_decimal_from_floatcCst|dd}|j|dS)a[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') >>> ExtendedContext.abs(-1) Decimal('1') TrrM)rrr1r/r*r*r,rn!s z Context.abscCs8t|dd}|j||d}|tkr0td|n|SdS)aReturn 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') >>> ExtendedContext.add(1, Decimal(2)) Decimal('3') >>> ExtendedContext.add(Decimal(8), 5) Decimal('13') >>> ExtendedContext.add(5, 5) Decimal('10') TrrMUnable to convert %s to DecimalN)rrrrxr1r/rurr*r*r,add6s  z Context.addcCst||Sr))rfrrr*r*r,_applyKszContext._applycCst|tstd|S)zReturns 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') z,canonical requires a Decimal as an argument.)rerrxrOrr*r*r,rONs zContext.canonicalcCst|dd}|j||dS)aCompares 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') >>> ExtendedContext.compare(1, 2) Decimal('-1') >>> ExtendedContext.compare(Decimal(1), 2) Decimal('-1') >>> ExtendedContext.compare(1, Decimal(2)) Decimal('-1') TrrM)rrr1r/rur*r*r,r[s! zContext.comparecCst|dd}|j||dS)aCompares 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 >>> c.compare_signal(-1, 2) Decimal('-1') >>> c.compare_signal(Decimal(-1), 2) Decimal('-1') >>> c.compare_signal(-1, Decimal(2)) Decimal('-1') TrrM)rrPrr*r*r,rPs zContext.compare_signalcCst|dd}||S)a+Compares 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') >>> ExtendedContext.compare_total(1, 2) Decimal('-1') >>> ExtendedContext.compare_total(Decimal(1), 2) Decimal('-1') >>> ExtendedContext.compare_total(1, Decimal(2)) Decimal('-1') Tr)rrLrr*r*r,rLs zContext.compare_totalcCst|dd}||S)zCompares two operands using their abstract representation ignoring sign. Like compare_total, but with operand's sign ignored and assumed to be 0. Tr)rrTrr*r*r,rTs zContext.compare_total_magcCst|dd}|S)aReturns 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') >>> ExtendedContext.copy_abs(-1) Decimal('1') Tr)rrrr*r*r,rs zContext.copy_abscCst|dd}t|S)aReturns a copy of the decimal object. >>> ExtendedContext.copy_decimal(Decimal('2.1')) Decimal('2.1') >>> ExtendedContext.copy_decimal(Decimal('-1.00')) Decimal('-1.00') >>> ExtendedContext.copy_decimal(1) Decimal('1') Tr)rrrr*r*r, copy_decimals zContext.copy_decimalcCst|dd}|S)a(Returns 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') >>> ExtendedContext.copy_negate(1) Decimal('-1') Tr)rrrr*r*r,rs zContext.copy_negatecCst|dd}||S)aCopies 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') >>> ExtendedContext.copy_sign(1, -2) Decimal('-1') >>> ExtendedContext.copy_sign(Decimal(1), -2) Decimal('-1') >>> ExtendedContext.copy_sign(1, Decimal(-2)) Decimal('-1') Tr)rrUrr*r*r,rUs zContext.copy_signcCs8t|dd}|j||d}|tkr0td|n|SdS)aDecimal 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') >>> ExtendedContext.divide(5, 5) Decimal('1') >>> ExtendedContext.divide(Decimal(5), 5) Decimal('1') >>> ExtendedContext.divide(5, Decimal(5)) Decimal('1') TrrMrN)rrrrxrr*r*r,divides  zContext.dividecCs8t|dd}|j||d}|tkr0td|n|SdS)a/Divides 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') >>> ExtendedContext.divide_int(10, 3) Decimal('3') >>> ExtendedContext.divide_int(Decimal(10), 3) Decimal('3') >>> ExtendedContext.divide_int(10, Decimal(3)) Decimal('3') TrrMrN)rrrrxrr*r*r, divide_int+s  zContext.divide_intcCs8t|dd}|j||d}|tkr0td|n|SdS)aReturn (a // b, a % b). >>> ExtendedContext.divmod(Decimal(8), Decimal(3)) (Decimal('2'), Decimal('2')) >>> ExtendedContext.divmod(Decimal(8), Decimal(4)) (Decimal('2'), Decimal('0')) >>> ExtendedContext.divmod(8, 4) (Decimal('2'), Decimal('0')) >>> ExtendedContext.divmod(Decimal(8), 4) (Decimal('2'), Decimal('0')) >>> ExtendedContext.divmod(8, Decimal(4)) (Decimal('2'), Decimal('0')) TrrMrN)rrrrxrr*r*r,rBs  zContext.divmodcCst|dd}|j|dS)a#Returns 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') >>> c.exp(10) Decimal('22026.4658') TrrM)rrXrr*r*r,rXWs z Context.expcCst|dd}|j|||dS)a 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') >>> ExtendedContext.fma(1, 3, 4) Decimal('7') >>> ExtendedContext.fma(1, Decimal(3), 4) Decimal('7') >>> ExtendedContext.fma(1, 3, Decimal(4)) Decimal('7') TrrM)rr)r1r/rurHr*r*r,ros z Context.fmacCst|tstd|S)aReturn 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 z/is_canonical requires a Decimal as an argument.)rerrxrXrr*r*r,rXs zContext.is_canonicalcCst|dd}|S)a,Return 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 >>> ExtendedContext.is_finite(1) True Tr)rrYrr*r*r,rYs zContext.is_finitecCst|dd}|S)aUReturn 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 >>> ExtendedContext.is_infinite(1) False Tr)rr?rr*r*r,r?s zContext.is_infinitecCst|dd}|S)aOReturn 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 >>> ExtendedContext.is_nan(1) False Tr)rrrr*r*r,rs zContext.is_nancCst|dd}|j|dS)aReturn 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 >>> c.is_normal(1) True TrrM)rr[rr*r*r,r[s zContext.is_normalcCst|dd}|S)aHReturn 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 >>> ExtendedContext.is_qnan(1) False Tr)rrrr*r*r,rs zContext.is_qnancCst|dd}|S)aReturn 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 >>> ExtendedContext.is_signed(8) False >>> ExtendedContext.is_signed(-8) True Tr)rr\rr*r*r,r\s zContext.is_signedcCst|dd}|S)aTReturn 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 >>> ExtendedContext.is_snan(1) False Tr)rrrr*r*r,rs zContext.is_snancCst|dd}|j|dS)aReturn 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 >>> c.is_subnormal(1) False TrrM)rr]rr*r*r,r]s zContext.is_subnormalcCst|dd}|S)auReturn 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 >>> ExtendedContext.is_zero(1) False >>> ExtendedContext.is_zero(0) True Tr)rr^rr*r*r,r^%s zContext.is_zerocCst|dd}|j|dS)aReturns 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') >>> c.ln(1) Decimal('0') TrrM)rrhrr*r*r,rh6s z Context.lncCst|dd}|j|dS)aReturns 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') >>> c.log10(0) Decimal('-Infinity') >>> c.log10(1) Decimal('0') TrrM)rrkrr*r*r,rkLs z Context.log10cCst|dd}|j|dS)a4 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') >>> ExtendedContext.logb(1) Decimal('0') >>> ExtendedContext.logb(10) Decimal('1') >>> ExtendedContext.logb(100) Decimal('2') TrrM)rrlrr*r*r,rlhs z Context.logbcCst|dd}|j||dS)aApplies 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') >>> ExtendedContext.logical_and(110, 1101) Decimal('100') >>> ExtendedContext.logical_and(Decimal(110), 1101) Decimal('100') >>> ExtendedContext.logical_and(110, Decimal(1101)) Decimal('100') TrrM)rrzrr*r*r,rzs zContext.logical_andcCst|dd}|j|dS)a Invert 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') >>> ExtendedContext.logical_invert(1101) Decimal('111110010') TrrM)rr|rr*r*r,r|s zContext.logical_invertcCst|dd}|j||dS)aApplies 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') >>> ExtendedContext.logical_or(110, 1101) Decimal('1111') >>> ExtendedContext.logical_or(Decimal(110), 1101) Decimal('1111') >>> ExtendedContext.logical_or(110, Decimal(1101)) Decimal('1111') TrrM)rr}rr*r*r,r}s zContext.logical_orcCst|dd}|j||dS)aApplies 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') >>> ExtendedContext.logical_xor(110, 1101) Decimal('1011') >>> ExtendedContext.logical_xor(Decimal(110), 1101) Decimal('1011') >>> ExtendedContext.logical_xor(110, Decimal(1101)) Decimal('1011') TrrM)rr{rr*r*r,r{s zContext.logical_xorcCst|dd}|j||dS)amax 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 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') >>> ExtendedContext.max(1, 2) Decimal('2') >>> ExtendedContext.max(Decimal(1), 2) Decimal('2') >>> ExtendedContext.max(1, Decimal(2)) Decimal('2') TrrM)rrrr*r*r,rs z Context.maxcCst|dd}|j||dS)aCompares the values numerically with their sign ignored. >>> ExtendedContext.max_mag(Decimal('7'), Decimal('NaN')) Decimal('7') >>> ExtendedContext.max_mag(Decimal('7'), Decimal('-10')) Decimal('-10') >>> ExtendedContext.max_mag(1, -2) Decimal('-2') >>> ExtendedContext.max_mag(Decimal(1), -2) Decimal('-2') >>> ExtendedContext.max_mag(1, Decimal(-2)) Decimal('-2') TrrM)rrrr*r*r,rs zContext.max_magcCst|dd}|j||dS)amin 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 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') >>> ExtendedContext.min(1, 2) Decimal('1') >>> ExtendedContext.min(Decimal(1), 2) Decimal('1') >>> ExtendedContext.min(1, Decimal(29)) Decimal('1') TrrM)rrrr*r*r,rs z Context.mincCst|dd}|j||dS)aCompares the values numerically with their sign ignored. >>> ExtendedContext.min_mag(Decimal('3'), Decimal('-2')) Decimal('-2') >>> ExtendedContext.min_mag(Decimal('-3'), Decimal('NaN')) Decimal('-3') >>> ExtendedContext.min_mag(1, -2) Decimal('1') >>> ExtendedContext.min_mag(Decimal(1), -2) Decimal('1') >>> ExtendedContext.min_mag(1, Decimal(-2)) Decimal('1') TrrM)rrrr*r*r,r-s zContext.min_magcCst|dd}|j|dS)aMinus 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') >>> ExtendedContext.minus(1) Decimal('-1') TrrM)rrrr*r*r,minus>s z Context.minuscCs8t|dd}|j||d}|tkr0td|n|SdS)amultiply 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') >>> ExtendedContext.multiply(7, 7) Decimal('49') >>> ExtendedContext.multiply(Decimal(7), 7) Decimal('49') >>> ExtendedContext.multiply(7, Decimal(7)) Decimal('49') TrrMrN)rrrrxrr*r*r,multiplyOs  zContext.multiplycCst|dd}|j|dS)a"Returns 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') >>> c.next_minus(1) Decimal('0.999999999') TrrM)rrrr*r*r,ros zContext.next_minuscCst|dd}|j|dS)aReturns 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') >>> c.next_plus(1) Decimal('1.00000001') TrrM)rrrr*r*r,rs zContext.next_pluscCst|dd}|j||dS)aReturns 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') >>> c.next_toward(0, 1) Decimal('1E-1007') >>> c.next_toward(Decimal(0), 1) Decimal('1E-1007') >>> c.next_toward(0, Decimal(1)) Decimal('1E-1007') TrrM)rrrr*r*r,rs zContext.next_towardcCst|dd}|j|dS)anormalize 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') >>> ExtendedContext.normalize(6) Decimal('6') TrrM)rr=rr*r*r,r=s zContext.normalizecCst|dd}|j|dS)aReturns 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 = ExtendedContext.copy() >>> 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' >>> c.number_class(123) '+Normal' TrrM)rrrr*r*r,rs/ zContext.number_classcCst|dd}|j|dS)aPlus 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') >>> ExtendedContext.plus(-1) Decimal('-1') TrrM)rrrr*r*r,pluss z Context.pluscCs:t|dd}|j|||d}|tkr2td|n|SdS)a 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') >>> ExtendedContext.power(7, 7) Decimal('823543') >>> ExtendedContext.power(Decimal(7), 7) Decimal('823543') >>> ExtendedContext.power(7, Decimal(7), 2) Decimal('1') TrrMrN)rr9rrx)r1r/rurrr*r*r,powers I z Context.powercCst|dd}|j||dS)a 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') >>> ExtendedContext.quantize(1, 2) Decimal('1') >>> ExtendedContext.quantize(Decimal(1), 2) Decimal('1') >>> ExtendedContext.quantize(1, Decimal(2)) Decimal('1') TrrM)rrrr*r*r,res7 zContext.quantizecCstdS)zkJust returns 10, as this is Decimal, :) >>> ExtendedContext.radix() Decimal('10') rrrr*r*r,rsz Context.radixcCs8t|dd}|j||d}|tkr0td|n|SdS)aReturns 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') >>> ExtendedContext.remainder(22, 6) Decimal('4') >>> ExtendedContext.remainder(Decimal(22), 6) Decimal('4') >>> ExtendedContext.remainder(22, Decimal(6)) Decimal('4') TrrMrN)rrrrxrr*r*r,rs  zContext.remaindercCst|dd}|j||dS)aGReturns 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') >>> ExtendedContext.remainder_near(3, 11) Decimal('3') >>> ExtendedContext.remainder_near(Decimal(3), 11) Decimal('3') >>> ExtendedContext.remainder_near(3, Decimal(11)) Decimal('3') TrrM)rrrr*r*r,rs zContext.remainder_nearcCst|dd}|j||dS)aNReturns 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') >>> ExtendedContext.rotate(1333333, 1) Decimal('13333330') >>> ExtendedContext.rotate(Decimal(1333333), 1) Decimal('13333330') >>> ExtendedContext.rotate(1333333, Decimal(1)) Decimal('13333330') TrrM)rrrr*r*r,rs zContext.rotatecCst|dd}||S)aReturns 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 >>> ExtendedContext.same_quantum(10000, -1) True >>> ExtendedContext.same_quantum(Decimal(10000), -1) True >>> ExtendedContext.same_quantum(10000, Decimal(-1)) True Tr)rr@rr*r*r,r@ s zContext.same_quantumcCst|dd}|j||dS)a3Returns 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') >>> ExtendedContext.scaleb(1, 4) Decimal('1E+4') >>> ExtendedContext.scaleb(Decimal(1), 4) Decimal('1E+4') >>> ExtendedContext.scaleb(1, Decimal(4)) Decimal('1E+4') TrrM)rrrr*r*r,r$s zContext.scalebcCst|dd}|j||dS)a{Returns 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') >>> ExtendedContext.shift(88888888, 2) Decimal('888888800') >>> ExtendedContext.shift(Decimal(88888888), 2) Decimal('888888800') >>> ExtendedContext.shift(88888888, Decimal(2)) Decimal('888888800') TrrM)rrrr*r*r,r7s z Context.shiftcCst|dd}|j|dS)aSquare 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.sqrt(2) Decimal('1.41421356') >>> ExtendedContext.prec 9 TrrM)rrJrr*r*r,rJUs z Context.sqrtcCs8t|dd}|j||d}|tkr0td|n|SdS)a&Return 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') >>> ExtendedContext.subtract(8, 5) Decimal('3') >>> ExtendedContext.subtract(Decimal(8), 5) Decimal('3') >>> ExtendedContext.subtract(8, Decimal(5)) Decimal('3') TrrMrN)rrrrxrr*r*r,subtractus  zContext.subtractcCst|dd}|j|dS)aConvert to a string, using engineering notation if an exponent is needed. Engineering notation has an exponent which is a multiple of 3. This can leave up to 3 digits to the left of the decimal place and may require the addition of either one or two trailing zeros. The operation is not affected by the context. >>> ExtendedContext.to_eng_string(Decimal('123E+1')) '1.23E+3' >>> ExtendedContext.to_eng_string(Decimal('123E+3')) '123E+3' >>> ExtendedContext.to_eng_string(Decimal('123E-10')) '12.3E-9' >>> ExtendedContext.to_eng_string(Decimal('-123E-12')) '-123E-12' >>> ExtendedContext.to_eng_string(Decimal('7E-7')) '700E-9' >>> ExtendedContext.to_eng_string(Decimal('7E+1')) '70' >>> ExtendedContext.to_eng_string(Decimal('0E+1')) '0.00E+3' TrrM)rrrr*r*r,rs zContext.to_eng_stringcCst|dd}|j|dS)zyConverts a number to a string, using scientific notation. The operation is not affected by the context. TrrM)rrrr*r*r, to_sci_strings zContext.to_sci_stringcCst|dd}|j|dS)akRounds 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') TrrM)rrDrr*r*r,rDs zContext.to_integral_exactcCst|dd}|j|dS)aLRounds 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') TrrM)rrrr*r*r,rs zContext.to_integral_value) NNNNNNNNN)N)rS)N)Xr5r6r7r8rrrrrrrrOrrErNrrjrrrrrrrFrrrnrrrOrrPrLrTrrrrUrrrrXrrXrYr?rr[rr\rr]r^rhrkrlrzr|r}r{rrrrrrrrrr=rrrrrrrrr@rrrJrrrrDrrr*r*r*r,rs $     $#   %  #2 P:&" c@s"eZdZdZdddZddZdS)rorDrWrXNcCsf|dkrd|_d|_d|_nFt|trD|j|_t|j|_|j|_n|d|_|d|_|d|_dS)Nr'r/r_)rDrWrXrerr<r=rQ)r1rzr*r*r,rs     z_WorkRep.__init__cCsd|j|j|jfS)Nz (%r, %r, %r)rrr*r*r,rsz_WorkRep.__repr__)N)r5r6r7rrrr*r*r*r,ros rocCs|j|jkr|}|}n|}|}tt|j}tt|j}|jtd||d}||jd|krpd|_||_|jd|j|j9_|j|_||fS)zcNormalizes op1, op2 to have the same exp and length of coefficient. Done during addition. rr_r/r)rXrlrfrWr)rrrGZtmprZtmp_lenZ other_lenrXr*r*r,rs rcCsb|dkr dS|dkr |d|Stt|}t|t|d}|| krPdS|d| SdS)a Given integers n and e, return n * 10**e if it's an integer, else None. The computation is designed to avoid computing large powers of 10 unnecessarily. >>> _decimal_lshift_exact(3, 4) 30000 >>> _decimal_lshift_exact(300, -999999999) # returns None r'rrSN)rfrnrlrstrip)r:rZstr_nZval_nr*r*r,r%(s   r%cCsB|dks|dkrtdd}||kr>||| |d?}}q|S)zClosest 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. r'z3Both arguments to _sqrt_nearest should be positive.r/)rr)r:r/rur*r*r, _sqrt_nearest=s rcCs2d|>||?}}|d||d@|d@|kS)zGiven an integer x and a nonnegative integer shift, return closest integer to x / 2**shift; use round-to-even in case of a tie. r/r_r*)r(rrurr*r*r,_rshift_nearestLsrcCs&t||\}}|d||d@|kS)zaClosest integer to a/b, a and b positive integers; rounds to even in the case of a tie. r_r/)r)r/rurrr*r*r, _div_nearestTsrrc Cs||}d}||kr(t|||>|ksD||krxt|||?|krxt||d>|t||t|||}|d7}q tdtt|d| }t||}t||}t|dddD]}t||t|||}qt|||S)aInteger 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.r'r/r]r)rnrrrrWrlrfr) r(MLr+RTZyshiftwrr*r*r,_ilog\s"    rc Cs|d7}tt|}||||dk}|dkrd|}|||}|dkrZ|d|9}nt|d| }t||}t|}t|||}||} nd}t|d| } t| |dS)zGiven 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.r_r/r'rr#)rlrfrr _log10_digits) rHrr'rIrrrlog_dZlog_10Z log_tenpowerr*r*r,rjs     rjc Cs|d7}tt|}||||dk}|dkrr|||}|dkrR|d|9}nt|d| }t|d|}nd}|rttt|d}||dkrt|t||d|}qd}nd}t||dS)zGiven 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.r_r/r'rr#)rlrfrrrnr) rHrr'rIrrrr8Z f_log_tenr*r*r,rfs"   rfc@s eZdZdZddZddZdS) _Log10MemoizezClass 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)NZ/23025850929940456840179914546843642076011014886)r~rr*r*r,rsz_Log10Memoize.__init__cCs|dkrtd|t|jkrd}d||d}tttd||d}|| dd|krbql|d7}q"|ddd |_t|jd|d S) ztGiven an integer p >= 0, return floor(10**p)*log(10). For example, self.getdigits(3) returns 2302. r'zp should be nonnegativer]rr_r#NrSrr/)rrrlr~rfrrrrW)r1r'r8rr~r*r*r, getdigitss  z_Log10Memoize.getdigitsN)r5r6r7r8rrr*r*r*r,rsrc Cst||>|}tdtt|d| }t||}||>}t|dddD]}t|||||}qPt|dddD]"}||d>}t||||}q|||S)zGiven 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).rr]r/r'rr_)r$rWrlrfrr) r(rrrrr+ZMshiftrrr*r*r,_iexps  rc Cs|d7}td|tt|d}||}||}|dkrH|d|}n|d| }t|t|\}}t|d|}tt|d|d||dfS)aCompute 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.r_r'r/rir])rrlrfrrrr) rHrr'r8rrZcshiftZquotr.r*r*r,rV$srVc Csttt||}t||||d}||}|dkrJ||d|}nt||d| }|dkrtt||dk|dkkrd|ddd|} } qd|d| } } n,t||d |d\} } t| d} | d7} | | fS)a5Given 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. r/r'r)rlrfrnrfrrV) r)r*r,r-r'ruZlxcrZpcrrXr*r*r,r3Hs r3r#F5(r_rr) r2345678rEcCs0|dkrtdt|}dt|||dS)z@Compute a lower bound for 100*log10(c) for a positive integer c.r'z0The argument to _log10_lb should be nonnegative.r#)rrrfrl)rHZ correctionZstr_cr*r*r,r&rsr&cCsLt|tr|St|tr t|S|r8t|tr8t|S|rHtd|tS)zConvert other to Decimal. Verifies that it's ok to use in an implicit construction. If allow_float is true, allow conversion from float; this is used in the comparison methods (__eq__ and friends). r)rerrWrvrwrxr)rrZ allow_floatr*r*r,r}s    rcCst|tr||fSt|tjrR|jsDt|jtt|j |j |j }|t|j fS|rrt|tj rr|jdkrr|j}t|trt}|rd|jt<n |td|t|fSttfS)zGiven a Decimal instance self and a Python object other, return a pair (s, o) of Decimal instances such that "s op o" is equivalent to "self op other" for any of the 6 comparison operators "op". r'r/rb)rer_numbersZRationalrRr;r<rfrWr= denominatorrQ numeratorZComplexrrrvrr6rrjrwr)r1rrr2r*r*r,rs(    rr"i?Bi)rGrFr5r6rHr>rrr`)rGrFr5r6a # A numeric string consists of: # \s* (?P[-+])? # an optional sign, followed by either... ( (?=\d|\.\d) # ...a number (with at least one digit) (?P\d*) # having a (possibly empty) integer part (\.(?P\d*))? # followed by an optional fractional part (E(?P[-+]?\d+))? # followed by an optional exponent, or... | Inf(inity)? # ...an infinity, or... | (?Ps)? # ...an (optionally signaling) NaN # NaN (?P\d*) # with (possibly empty) diagnostic info. ) # \s* \Z z0*$z50*$z\A (?: (?P.)? (?P[<>=^]) )? (?P[-+ ])? (?P\#)? (?P0)? (?P(?!0)\d+)? (?P,)? (?:\.(?P0|(?!0)\d+))? (?P[eEfFgGn%])? \Z cCst|}|dkrtd||}|d}|d}|ddk |d<|drv|dk rbtd||dk rvtd||p|d|d<|pd |d<|d dkrd |d <t|d pd |d <|ddk rt|d|d<|ddkr|ddks|ddkrd|d<|ddkrfd|d<|dkr&t}|ddk r@td||d|d<|d|d<|d|d<n*|ddkr|d|d<ddg|d<d|d<|S)aParse and validate a format specifier. Turns a standard numeric format specifier into a dict, with the following entries: fill: fill character to pad field to minimum width align: alignment type, either '<', '>', '=' or '^' sign: either '+', '-' or ' ' minimumwidth: nonnegative integer giving minimum width zeropad: boolean, indicating whether to pad with zeros thousands_sep: string to use as thousands separator, or '' grouping: grouping for thousands separators, in format used by localeconv decimal_point: string to use for decimal point precision: nonnegative integer giving precision, or None type: one of the characters 'eEfFgG%', or None NzInvalid format specifier: fillalignzeropadz7Fill character conflicts with '0' in format specifier: z2Alignment conflicts with '0' in format specifier:  >rDrV minimumwidthrSrr'rZgGnr/r:r thousands_sepzJExplicit thousands separator conflicts with 'n' type in format specifier: grouping decimal_pointrUr]r)_parse_format_specifier_regexmatchrr groupdictrW_locale localeconv) format_specrr{Z format_dictrrr*r*r,rsT           rc Cs|d}|d}||t|t|}|d}|dkrF|||}nj|dkr\|||}nT|dkrr|||}n>|dkrt|d}|d |||||d }ntd |S) zGiven an unpadded, non-aligned numeric string 'body' and sign string 'sign', add padding and alignment conforming to the given format specifier dictionary 'spec' (as produced by parse_format_specifier). r rrse#          &   .  ^  0",# %$+  *       P % )