Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
3f122784
Commit
3f122784
authored
Dec 11, 2008
by
Mark Dickinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #4084: fix bug in handling of NaNs in Decimal.max, Decimal.min,
Decimal.max_mag and Decimal.min_mag.
parent
2443efb7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
16 deletions
+37
-16
Lib/decimal.py
Lib/decimal.py
+16
-16
Lib/test/decimaltestdata/extra.decTest
Lib/test/decimaltestdata/extra.decTest
+17
-0
Misc/NEWS
Misc/NEWS
+4
-0
No files found.
Lib/decimal.py
View file @
3f122784
...
...
@@ -2430,10 +2430,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
)
...
...
@@ -2472,10 +2472,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
)
...
...
@@ -3043,10 +3043,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
())
...
...
@@ -3073,10 +3073,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
())
...
...
Lib/test/decimaltestdata/extra.decTest
View file @
3f122784
...
...
@@ -154,6 +154,23 @@ extr1301 fma Inf 0 sNaN456 -> NaN Invalid_operation
extr1302 fma 0E123 -Inf sNaN789 -> NaN Invalid_operation
extr1302 fma -Inf 0E-456 sNaN148 -> NaN Invalid_operation
-- max/min/max_mag/min_mag bug in 2.5.2/2.6/3.0: max(NaN, finite) gave
-- incorrect answers when the finite number required rounding; similarly
-- for the other thre functions
maxexponent: 999
minexponent: -999
precision: 6
rounding: half_even
extr1400 max NaN 1234567 -> 1.23457E+6 Inexact Rounded
extr1401 max 3141590E-123 NaN1729 -> 3.14159E-117 Rounded
extr1402 max -7.654321 -NaN -> -7.65432 Inexact Rounded
extr1410 min -NaN -765432.1 -> -765432 Inexact Rounded
extr1411 min 3141592 NaN -> 3.14159E+6 Inexact Rounded
extr1420 max_mag 0.1111111 -NaN123 -> 0.111111 Inexact Rounded
extr1421 max_mag NaN999999999 0.001234567 -> 0.00123457 Inexact Rounded
extr1430 min_mag 9181716151 -NaN -> 9.18172E+9 Inexact Rounded
extr1431 min_mag NaN4 1.818180E100 -> 1.81818E+100 Rounded
-- Tests for the is_* boolean operations
precision: 9
maxExponent: 999
...
...
Misc/NEWS
View file @
3f122784
...
...
@@ -107,6 +107,10 @@ Core and builtins
Library
-------
-
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
.
-
Issue
#
1776581
and
#
4302.
Minor
corrections
to
smtplib
.
-
Issue
#
3774
:
Fixed
an
error
when
create
a
Tkinter
menu
item
without
command
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment