Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-123836: workaround fmod(x, y) bug on Windows#124171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
vstinner merged 7 commits intopython:mainfromskirpichev:fix-fmod-win-123854
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Move workaround to math_fmod_impl
  • Loading branch information
@skirpichev
skirpichev committedSep 17, 2024
commitfbecd8b68274c0f9da83e357497f7119857777fd
16 changes: 0 additions & 16 deletionsModules/_math.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,19 +23,3 @@ _Py_log1p(double x)
}

#define m_log1p _Py_log1p

static double
_Py_fmod(double x, double y)
{
/* Some platforms (e.g. Windows 10 with MSC v.1916) loose sign
for zero result. But C99+ says: "if y is nonzero, the result
has the same sign as x".
*/
double r = fmod(x, y);

if (r == 0.0 && y != 0.0) {
r = copysign(r, x);
}

return r;
}
9 changes: 8 additions & 1 deletionModules/mathmodule.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2347,7 +2347,14 @@ math_fmod_impl(PyObject *module, double x, double y)
if (isinf(y) && isfinite(x))
return PyFloat_FromDouble(x);
errno = 0;
r = _Py_fmod(x, y);
r = fmod(x, y);
/* Some platforms (e.g. Windows 10 with MSC v.1916) loose sign
for zero result. But C99+ says: "if y is nonzero, the result
has the same sign as x".
*/
if (r == 0.0 && y != 0.0) {
r = copysign(r, x);
}
if (isnan(r)) {
if (!isnan(x) && !isnan(y))
errno = EDOM;
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp