pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/f4dd4402108cc005d45acd4ca83c8530c36a93ca

5097560d244c08.css" /> gh-123836: workaround fmod(x, y) bug on Windows (#124171) · python/cpython@f4dd440 · GitHub
Skip to content

Commit f4dd440

Browse files
authored
gh-123836: workaround fmod(x, y) bug on Windows (#124171)
Buildbot failure on Windows 10 with MSC v.1916 64 bit (AMD64): FAIL: testFmod (test.test_math.MathTests.testFmod) ---------------------------------------------------------------------- Traceback (most recent call last): File "D:\buildarea\3.x.bolen-windows10\build\Lib\test\test_math.py", line 605, in testFmod self.ftest('fmod(-10, 1)', math.fmod(-10, 1), -0.0) ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\buildarea\3.x.bolen-windows10\build\Lib\test\test_math.py", line 258, in ftest self.fail("{}: {}".format(name, failure)) ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: fmod(-10, 1): expected -0.0, got 0.0 (zero has wrong sign) Here Windows loose sign of the result; if y is nonzero, the result should have the same sign as x. This amends commit 28aea5d.
1 parent f15fff3 commit f4dd440

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Add workaround for broken :c:func:`!fmod()` implementations on Windows, that
2+
loose zero sign (e.g. ``fmod(-10, 1)`` returns ``0.0``). Patch by Sergey B
3+
Kirpichev.

Modules/mathmodule.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2348,6 +2348,15 @@ math_fmod_impl(PyObject *module, double x, double y)
23482348
return PyFloat_FromDouble(x);
23492349
errno = 0;
23502350
r = fmod(x, y);
2351+
#ifdef _MSC_VER
2352+
/* Windows (e.g. Windows 10 with MSC v.1916) loose sign
2353+
for zero result. But C99+ says: "if y is nonzero, the result
2354+
has the same sign as x".
2355+
*/
2356+
if (r == 0.0 && y != 0.0) {
2357+
r = copysign(r, x);
2358+
}
2359+
#endif
23512360
if (isnan(r)) {
23522361
if (!isnan(x) && !isnan(y))
23532362
errno = EDOM;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy