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
85d02fa4
Commit
85d02fa4
authored
Aug 18, 2012
by
Mark Dickinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #15477: Add workaround for log1p(-0.0) on platforms where it's broken.
parent
9d90dada
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
10 deletions
+28
-10
Lib/test/test_cmath.py
Lib/test/test_cmath.py
+0
-4
Misc/NEWS
Misc/NEWS
+3
-0
Modules/_math.c
Modules/_math.c
+23
-0
Modules/_math.h
Modules/_math.h
+2
-6
No files found.
Lib/test/test_cmath.py
View file @
85d02fa4
...
...
@@ -519,15 +519,11 @@ class CMathTests(unittest.TestCase):
# of zero, then atan and atanh will also have difficulties with
# the sign of complex zeros.
@
requires_IEEE_754
@
unittest
.
skipIf
(
sysconfig
.
get_config_var
(
'LOG1P_DROPS_ZERO_SIGN'
),
"system log1p() function doesn't preserve the sign"
)
def
testAtanSign
(
self
):
for
z
in
complex_zeros
:
self
.
assertComplexIdentical
(
cmath
.
atan
(
z
),
z
)
@
requires_IEEE_754
@
unittest
.
skipIf
(
sysconfig
.
get_config_var
(
'LOG1P_DROPS_ZERO_SIGN'
),
"system log1p() function doesn't preserve the sign"
)
def
testAtanhSign
(
self
):
for
z
in
complex_zeros
:
self
.
assertComplexIdentical
(
cmath
.
atanh
(
z
),
z
)
...
...
Misc/NEWS
View file @
85d02fa4
...
...
@@ -104,6 +104,9 @@ Core and Builtins
Library
-------
- Issue #15477: In cmath and math modules, add workaround for platforms whose
system-supplied log1p function doesn't respect signs of zeros.
- Issue #11062: Fix adding a message from file to Babyl mailbox.
- Issue #15646: Prevent equivalent of a fork bomb when using
...
...
Modules/_math.c
View file @
85d02fa4
...
...
@@ -189,6 +189,27 @@ _Py_expm1(double x)
significant loss of precision that arises from direct evaluation when x is
small. */
#ifdef HAVE_LOG1P
double
_Py_log1p
(
double
x
)
{
/* Some platforms supply a log1p function but don't respect the sign of
zero: log1p(-0.0) gives 0.0 instead of the correct result of -0.0.
To save fiddling with configure tests and platform checks, we handle the
special case of zero input directly on all platforms.
*/
if
(
x
==
0
.
0
)
{
return
x
;
}
else
{
return
log1p
(
x
);
}
}
#else
double
_Py_log1p
(
double
x
)
{
...
...
@@ -230,3 +251,5 @@ _Py_log1p(double x)
return
log
(
1
.
+
x
);
}
}
#endif
/* ifdef HAVE_LOG1P */
Modules/_math.h
View file @
85d02fa4
...
...
@@ -36,10 +36,6 @@ double _Py_log1p(double x);
#define m_expm1 _Py_expm1
#endif
#ifdef HAVE_LOG1P
#define m_log1p log1p
#else
/* if the system doesn't have log1p, use the substitute
function defined in Modules/_math.c. */
/* Use the substitute from _math.c on all platforms:
it includes workarounds for buggy handling of zeros. */
#define m_log1p _Py_log1p
#endif
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