summaryrefslogtreecommitdiffstats
path: root/Lib/decimal.py
diff options
context:
space:
mode:
authorFacundo Batista <facundobatista@gmail.com>2008-12-11 04:19:46 (GMT)
committerFacundo Batista <facundobatista@gmail.com>2008-12-11 04:19:46 (GMT)
commite29d435e0cefb3e1772f6de0844e628aac3cf98e (patch)
tree1fb28cdfbbc38c424bd7f3f911db0893f456dd0c /Lib/decimal.py
parent240028cb771d286b39952357802483cf6a5d7e2e (diff)
downloadcpython-e29d435e0cefb3e1772f6de0844e628aac3cf98e.zip
cpython-e29d435e0cefb3e1772f6de0844e628aac3cf98e.tar.gz
cpython-e29d435e0cefb3e1772f6de0844e628aac3cf98e.tar.bz2
Issue #4084: Fix max, min, max_mag and min_mag Decimal methods to
give correct results in the case where one argument is a quiet NaN and the other is a finite number that requires rounding. Thanks Mark Dickinson.
Diffstat (limited to 'Lib/decimal.py')
-rw-r--r--Lib/decimal.py32
1 files changed, 16 insertions, 16 deletions
diff --git a/Lib/decimal.py b/Lib/decimal.py
index 795b40f..c427844 100644
--- a/Lib/decimal.py
+++ b/Lib/decimal.py
@@ -2563,10 +2563,10 @@ class Decimal(object):
sn = self._isnan()
on = other._isnan()
if sn or on:
- if on == 1 and sn != 2:
- return self._fix_nan(context)
- if sn == 1 and on != 2:
- return other._fix_nan(context)
+ if on == 1 and sn == 0:
+ return self._fix(context)
+ if sn == 1 and on == 0:
+ return other._fix(context)
return self._check_nans(other, context)
c = self._cmp(other)
@@ -2605,10 +2605,10 @@ class Decimal(object):
sn = self._isnan()
on = other._isnan()
if sn or on:
- if on == 1 and sn != 2:
- return self._fix_nan(context)
- if sn == 1 and on != 2:
- return other._fix_nan(context)
+ if on == 1 and sn == 0:
+ return self._fix(context)
+ if sn == 1 and on == 0:
+ return other._fix(context)
return self._check_nans(other, context)
c = self._cmp(other)
@@ -3163,10 +3163,10 @@ class Decimal(object):
sn = self._isnan()
on = other._isnan()
if sn or on:
- if on == 1 and sn != 2:
- return self._fix_nan(context)
- if sn == 1 and on != 2:
- return other._fix_nan(context)
+ if on == 1 and sn == 0:
+ return self._fix(context)
+ if sn == 1 and on == 0:
+ return other._fix(context)
return self._check_nans(other, context)
c = self.copy_abs()._cmp(other.copy_abs())
@@ -3193,10 +3193,10 @@ class Decimal(object):
sn = self._isnan()
on = other._isnan()
if sn or on:
- if on == 1 and sn != 2:
- return self._fix_nan(context)
- if sn == 1 and on != 2:
- return other._fix_nan(context)
+ if on == 1 and sn == 0:
+ return self._fix(context)
+ if sn == 1 and on == 0:
+ return other._fix(context)
return self._check_nans(other, context)
c = self.copy_abs()._cmp(other.copy_abs())