summaryrefslogtreecommitdiffstats
path: root/Python/fmod.c
blob: 919c6cc74650f79415ac38a9e3df481c25e46686 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

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

#include "pyconfig.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;
}
1 Tcl is a high-level, general-purpose, interpreted, dynamic programming language. It was designed with the goal of being very simple but powerful.
summaryrefslogtreecommitdiffstats
BranchCommit messageAuthorAge
amg_string_insertSimplify implementation of non-bytecoded [string replace]andy8 years
cjo_hydramerge tip-445dgp8 years
core_zip_vfsImprovements to Tip#430 based on community input. Added a forward declaration...hypnotoad8 years
dgp_properbytearraymerge novemdgp8 years
dgp_refactorRefactor code common to merge and insert.dgp8 years
libtommath'const'ify all libtommath functions, will appear in next libtommath version. ...jan.nijtmans8 years
masterMerge latest 'const'ification changes from libtommath (develop branch, will b...jan.nijtmans8 years
novemMerge trunkjan.nijtmans8 years
tip_445More TIP 445 conversion of the "path" Tcl_ObjType.dgp8 years
vc_reformAdd default-* targetsapnadkarni8 years
[...]
 
TagDownloadAuthorAge
core-minizip-no-tinydircore-minizip-no-tinydir.zip  core-minizip-no-tinydir.tar.gz  core-minizip-no-tinydir.tar.bz2  jan.nijtmans2 weeks
core-bug-602971aecore-bug-602971ae.zip  core-bug-602971ae.tar.gz  core-bug-602971ae.tar.bz2  apnadkarni3 weeks
core-new-timer-apicore-new-timer-api.zip  core-new-timer-api.tar.gz  core-new-timer-api.tar.bz2  jan.nijtmans5 weeks
core-timer-optimisation-haocore-timer-optimisation-hao.zip  core-timer-optimisation-hao.tar.gz  core-timer-optimisation-hao.tar.bz2  oehhar6 weeks
tip-744-pre-nowinerrortip-744-pre-nowinerror.zip  tip-744-pre-nowinerror.tar.gz  tip-744-pre-nowinerror.tar.bz2  apnadkarni8 weeks
core-apn-avoid-join-shimmercore-apn-avoid-join-shimmer.zip  core-apn-avoid-join-shimmer.tar.gz  core-apn-avoid-join-shimmer.tar.bz2  apnadkarni8 weeks
core-c11-functionscore-c11-functions.zip  core-c11-functions.tar.gz  core-c11-functions.tar.bz2  dkf8 weeks
core-bug-59bee3a3a7core-bug-59bee3a3a7.zip  core-bug-59bee3a3a7.tar.gz  core-bug-59bee3a3a7.tar.bz2  apnadkarni8 weeks
core-bug-7b46bc7f85core-bug-7b46bc7f85.zip  core-bug-7b46bc7f85.tar.gz  core-bug-7b46bc7f85.tar.bz2  apnadkarni8 weeks
core-bug-983f933f11core-bug-983f933f11.zip  core-bug-983f933f11.tar.gz  core-bug-983f933f11.tar.bz2  apnadkarni8 weeks
[...]