Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
76e60d68
Commit
76e60d68
authored
Oct 20, 2004
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SF bug #1048728: Bug fixes and cleanup for decimal.py
(Contributed by Neal Norwitz. Reviewed by Facundo Bastista.)
parent
9414ded8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
13 deletions
+7
-13
Lib/decimal.py
Lib/decimal.py
+7
-13
No files found.
Lib/decimal.py
View file @
76e60d68
...
...
@@ -136,7 +136,6 @@ __all__ = [
import
threading
import
copy
import
operator
#Rounding
ROUND_DOWN
=
'ROUND_DOWN'
...
...
@@ -1716,14 +1715,11 @@ class Decimal(object):
val
=
Decimal
(
1
)
context
=
context
.
_shallow_copy
()
context
.
prec
=
firstprec
+
elength
+
1
rounding
=
context
.
rounding
if
n
<
0
:
#n is a long now, not Decimal instance
n
=
-
n
mul
=
Decimal
(
1
).
__div__
(
mul
,
context
=
context
)
shouldround
=
context
.
_rounding_decision
==
ALWAYS_ROUND
spot
=
1
while
spot
<=
n
:
spot
<<=
1
...
...
@@ -1742,7 +1738,7 @@ class Decimal(object):
spot
>>=
1
context
.
prec
=
firstprec
if
shouldround
:
if
context
.
_rounding_decision
==
ALWAYS_ROUND
:
return
val
.
_fix
(
context
)
return
val
...
...
@@ -1823,8 +1819,6 @@ class Decimal(object):
if
ans
:
return
ans
out
=
0
if
watchexp
and
(
context
.
Emax
<
exp
or
context
.
Etiny
()
>
exp
):
return
context
.
_raise_error
(
InvalidOperation
,
'rescale(a, INF)'
)
...
...
@@ -1844,7 +1838,6 @@ class Decimal(object):
tmp
.
_int
=
(
0
,)
+
tmp
.
_int
digits
+=
1
prevexact
=
context
.
flags
[
Inexact
]
if
digits
<
0
:
tmp
.
_exp
=
-
digits
+
tmp
.
_exp
tmp
.
_int
=
(
0
,
1
)
...
...
@@ -1940,7 +1933,6 @@ class Decimal(object):
half
=
Decimal
(
'0.5'
)
count
=
1
maxp
=
firstprec
+
2
rounding
=
context
.
_set_rounding
(
ROUND_HALF_EVEN
)
while
1
:
...
...
@@ -2043,8 +2035,9 @@ class Decimal(object):
if
context
is
None
:
context
=
getcontext
()
context
.
_rounding_decision
==
ALWAYS_ROUND
return
ans
.
_fix
(
context
)
if
context
.
_rounding_decision
==
ALWAYS_ROUND
:
return
ans
.
_fix
(
context
)
return
ans
def
min
(
self
,
other
,
context
=
None
):
"""Returns the smaller value.
...
...
@@ -2089,8 +2082,9 @@ class Decimal(object):
if
context
is
None
:
context
=
getcontext
()
context
.
_rounding_decision
==
ALWAYS_ROUND
return
ans
.
_fix
(
context
)
if
context
.
_rounding_decision
==
ALWAYS_ROUND
:
return
ans
.
_fix
(
context
)
return
ans
def
_isinteger
(
self
):
"""Returns whether self is an integer"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment