Staging
v0.5.1
https://github.com/python/cpython
Revision 98cf19babe16df35c4a88603b0fc012b720e909e authored by Moshe Zadka on 31 March 2001, 13:46:34 UTC, committed by Moshe Zadka on 31 March 2001, 13:46:34 UTC
- Made statcache.forget_dir more portable
1 parent 805e7c6
Raw File
Tip revision: 98cf19babe16df35c4a88603b0fc012b720e909e authored by Moshe Zadka on 31 March 2001, 13:46:34 UTC
- #130306 - statcache.py - full of thread problems.
Tip revision: 98cf19b
fmod.c

/* Portable fmod(x, y) implementation for systems that don't have it */

#include "config.h"

#include "pyport.h"
#include <errno.h>

double
fmod(double x, double y)
{
	double i, f;
	
	if (y == 0.0) {
		errno = EDOM;
		return 0.0;
	}
	
	/* return f such that x = i*y + f for some integer i
	   such that |f| < |y| and f has the same sign as x */
	
	i = floor(x/y);
	f = x - i*y;
	if ((x < 0.0) != (y < 0.0))
		f = f-y;
	return f;
}
back to top