diff options
Diffstat (limited to 'Lib/decimal.py')
-rw-r--r-- | Lib/decimal.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/Lib/decimal.py b/Lib/decimal.py index 7384d3692f..be1a82783f 100644 --- a/Lib/decimal.py +++ b/Lib/decimal.py @@ -2723,6 +2723,8 @@ class Decimal(object): value. Note that a total ordering is defined for all possible abstract representations. """ + other = _convert_other(other, raiseit=True) + # if one is negative and the other is positive, it's easy if self._sign and not other._sign: return _NegativeOne @@ -2792,6 +2794,8 @@ class Decimal(object): Like compare_total, but with operand's sign ignored and assumed to be 0. """ + other = _convert_other(other, raiseit=True) + s = self.copy_abs() o = other.copy_abs() return s.compare_total(o) @@ -3160,6 +3164,9 @@ class Decimal(object): """Applies an 'and' operation between self and other's digits.""" if context is None: context = getcontext() + + other = _convert_other(other, raiseit=True) + if not self._islogical() or not other._islogical(): return context._raise_error(InvalidOperation) @@ -3181,6 +3188,9 @@ class Decimal(object): """Applies an 'or' operation between self and other's digits.""" if context is None: context = getcontext() + + other = _convert_other(other, raiseit=True) + if not self._islogical() or not other._islogical(): return context._raise_error(InvalidOperation) @@ -3195,6 +3205,9 @@ class Decimal(object): """Applies an 'xor' operation between self and other's digits.""" if context is None: context = getcontext() + + other = _convert_other(other, raiseit=True) + if not self._islogical() or not other._islogical(): return context._raise_error(InvalidOperation) @@ -3408,6 +3421,8 @@ class Decimal(object): if context is None: context = getcontext() + other = _convert_other(other, raiseit=True) + ans = self._check_nans(other, context) if ans: return ans @@ -3432,11 +3447,13 @@ class Decimal(object): return _dec_from_triple(self._sign, rotated.lstrip('0') or '0', self._exp) - def scaleb (self, other, context=None): + def scaleb(self, other, context=None): """Returns self operand after adding the second value to its exp.""" if context is None: context = getcontext() + other = _convert_other(other, raiseit=True) + ans = self._check_nans(other, context) if ans: return ans @@ -3460,6 +3477,8 @@ class Decimal(object): if context is None: context = getcontext() + other = _convert_other(other, raiseit=True) + ans = self._check_nans(other, context) if ans: return ans |