Added WatchedFileHandler (based on SF patch #1598415)
[python.git] / Python / fmod.c
blob919c6cc74650f79415ac38a9e3df481c25e46686
2 /* Portable fmod(x, y) implementation for systems that don't have it */
4 #include "pyconfig.h"
6 #include "pyport.h"
7 #include <errno.h>
9 double
10 fmod(double x, double y)
12 double i, f;
14 if (y == 0.0) {
15 errno = EDOM;
16 return 0.0;
19 /* return f such that x = i*y + f for some integer i
20 such that |f| < |y| and f has the same sign as x */
22 i = floor(x/y);
23 f = x - i*y;
24 if ((x < 0.0) != (y < 0.0))
25 f = f-y;
26 return f;