mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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.
This commit is contained in:
parent
10b24e87e5
commit
708d58179d
3 changed files with 37 additions and 16 deletions
|
@ -2651,10 +2651,10 @@ class Decimal(_numbers.Real):
|
|||
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)
|
||||
|
@ -2693,10 +2693,10 @@ class Decimal(_numbers.Real):
|
|||
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)
|
||||
|
@ -3251,10 +3251,10 @@ class Decimal(_numbers.Real):
|
|||
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())
|
||||
|
@ -3281,10 +3281,10 @@ class Decimal(_numbers.Real):
|
|||
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())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue