[Python-checkins] python/dist/src/Lib decimal.py,1.27,1.28
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Wed Oct 20 08:58:31 CEST 2004
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1503
Modified Files:
decimal.py
Log Message:
SF bug #1048728: Bug fixes and cleanup for decimal.py
(Contributed by Neal Norwitz. Reviewed by Facundo Bastista.)
Index: decimal.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- decimal.py 12 Oct 2004 09:12:16 -0000 1.27
+++ decimal.py 20 Oct 2004 06:58:28 -0000 1.28
@@ -136,7 +136,6 @@
import threading
import copy
-import operator
#Rounding
ROUND_DOWN = 'ROUND_DOWN'
@@ -1716,14 +1715,11 @@
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 @@
spot >>= 1
context.prec = firstprec
- if shouldround:
+ if context._rounding_decision == ALWAYS_ROUND:
return val._fix(context)
return val
@@ -1823,8 +1819,6 @@
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 @@
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 @@
half = Decimal('0.5')
- count = 1
maxp = firstprec + 2
rounding = context._set_rounding(ROUND_HALF_EVEN)
while 1:
@@ -2043,8 +2035,9 @@
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 @@
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"""
More information about the Python-checkins
mailing list