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
33154388
Commit
33154388
authored
Dec 04, 2010
by
Mark Dickinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backout broken backport. (Sorry.)
parent
11e77ffc
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
38 deletions
+14
-38
Lib/test/test_float.py
Lib/test/test_float.py
+10
-20
Misc/NEWS
Misc/NEWS
+0
-4
Objects/floatobject.c
Objects/floatobject.c
+4
-14
No files found.
Lib/test/test_float.py
View file @
33154388
...
@@ -12,6 +12,16 @@ import re
...
@@ -12,6 +12,16 @@ import re
INF
=
float
(
"inf"
)
INF
=
float
(
"inf"
)
NAN
=
float
(
"nan"
)
NAN
=
float
(
"nan"
)
have_getformat
=
hasattr
(
float
,
"__getformat__"
)
requires_getformat
=
unittest
.
skipUnless
(
have_getformat
,
"requires __getformat__"
)
requires_setformat
=
unittest
.
skipUnless
(
hasattr
(
float
,
"__setformat__"
),
"requires __setformat__"
)
# decorator for skipping tests on non-IEEE 754 platforms
requires_IEEE_754
=
unittest
.
skipUnless
(
have_getformat
and
float
.
__getformat__
(
"double"
).
startswith
(
"IEEE"
),
"test requires IEEE 754 doubles"
)
#locate file with float format test values
#locate file with float format test values
test_dir
=
os
.
path
.
dirname
(
__file__
)
or
os
.
curdir
test_dir
=
os
.
path
.
dirname
(
__file__
)
or
os
.
curdir
format_testfile
=
os
.
path
.
join
(
test_dir
,
'formatfloat_testcases.txt'
)
format_testfile
=
os
.
path
.
join
(
test_dir
,
'formatfloat_testcases.txt'
)
...
@@ -231,26 +241,6 @@ class GeneralFloatCases(unittest.TestCase):
...
@@ -231,26 +241,6 @@ class GeneralFloatCases(unittest.TestCase):
self
.
assertTrue
(
d
==
d
,
"{%r : None} not equal to itself"
%
f
)
self
.
assertTrue
(
d
==
d
,
"{%r : None} not equal to itself"
%
f
)
@
requires_IEEE_754
def
test_float_mod
(
self
):
# Check behaviour of % operator for IEEE 754 special cases.
# In particular, check signs of zeros.
mod
=
operator
.
mod
self
.
assertEqualAndEqualSign
(
mod
(
-
1.0
,
1.0
),
0.0
)
self
.
assertEqualAndEqualSign
(
mod
(
-
1e-100
,
1.0
),
1.0
)
self
.
assertEqualAndEqualSign
(
mod
(
-
0.0
,
1.0
),
0.0
)
self
.
assertEqualAndEqualSign
(
mod
(
0.0
,
1.0
),
0.0
)
self
.
assertEqualAndEqualSign
(
mod
(
1e-100
,
1.0
),
1e-100
)
self
.
assertEqualAndEqualSign
(
mod
(
1.0
,
1.0
),
0.0
)
self
.
assertEqualAndEqualSign
(
mod
(
-
1.0
,
-
1.0
),
-
0.0
)
self
.
assertEqualAndEqualSign
(
mod
(
-
1e-100
,
-
1.0
),
-
1e-100
)
self
.
assertEqualAndEqualSign
(
mod
(
-
0.0
,
-
1.0
),
-
0.0
)
self
.
assertEqualAndEqualSign
(
mod
(
0.0
,
-
1.0
),
-
0.0
)
self
.
assertEqualAndEqualSign
(
mod
(
1e-100
,
-
1.0
),
-
1.0
)
self
.
assertEqualAndEqualSign
(
mod
(
1.0
,
-
1.0
),
-
0.0
)
class
FormatFunctionsTestCase
(
unittest
.
TestCase
):
class
FormatFunctionsTestCase
(
unittest
.
TestCase
):
...
...
Misc/NEWS
View file @
33154388
...
@@ -10,10 +10,6 @@ What's New in Python 3.1.4?
...
@@ -10,10 +10,6 @@ What's New in Python 3.1.4?
Core and Builtins
Core and Builtins
-----------------
-----------------
- Issue #10596: Fix float.__mod__ to have the same behaviour as
float.__divmod__ with respect to signed zeros. -4.0 % 4.0 should be
0.0, not -0.0.
Library
Library
-------
-------
...
...
Objects/floatobject.c
View file @
33154388
...
@@ -600,21 +600,11 @@ float_rem(PyObject *v, PyObject *w)
...
@@ -600,21 +600,11 @@ float_rem(PyObject *v, PyObject *w)
#endif
#endif
PyFPE_START_PROTECT
(
"modulo"
,
return
0
)
PyFPE_START_PROTECT
(
"modulo"
,
return
0
)
mod
=
fmod
(
vx
,
wx
);
mod
=
fmod
(
vx
,
wx
);
if
(
mod
)
{
/* note: checking mod*wx < 0 is incorrect -- underflows to
/* ensure the remainder has the same sign as the denominator
*/
0 if wx < sqrt(smallest nonzero double)
*/
if
((
wx
<
0
)
!=
(
mod
<
0
))
{
if
(
mod
&&
((
wx
<
0
)
!=
(
mod
<
0
)
))
{
mod
+=
wx
;
mod
+=
wx
;
}
}
}
else
{
/* the remainder is zero, and in the presence of signed zeroes
fmod returns different results across platforms; ensure
it has the same sign as the denominator; we'd like to do
"mod = wx * 0.0", but that may get optimized away */
mod
*=
mod
;
/* hide "mod = +0" from optimizer */
if
(
wx
<
0
.
0
)
mod
=
-
mod
;
}
PyFPE_END_PROTECT
(
mod
)
PyFPE_END_PROTECT
(
mod
)
return
PyFloat_FromDouble
(
mod
);
return
PyFloat_FromDouble
(
mod
);
}
}
...
...
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