mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Issue #15477: Add workaround for log1p(-0.0) on platforms where it's broken.
This commit is contained in:
parent
31a11902b3
commit
05d79e9abf
4 changed files with 28 additions and 10 deletions
|
@ -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 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue