import threading
import copy
-import operator
#Rounding
ROUND_DOWN = 'ROUND_DOWN'
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
spot >>= 1
context.prec = firstprec
- if shouldround:
+ if context._rounding_decision == ALWAYS_ROUND:
return val._fix(context)
return val
if ans:
return ans
- out = 0
-
if watchexp and (context.Emax < exp or context.Etiny() > exp):
return context._raise_error(InvalidOperation, 'rescale(a, INF)')
tmp._int = (0,) + tmp._int
digits += 1
- prevexact = context.flags[Inexact]
if digits < 0:
tmp._exp = -digits + tmp._exp
tmp._int = (0,1)
half = Decimal('0.5')
- count = 1
maxp = firstprec + 2
rounding = context._set_rounding(ROUND_HALF_EVEN)
while 1:
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.
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"""