History

add hg and python

cinap_lenrek committed 15 years ago

Commit 4bb9e221 parent 987265c3706 files · +1228772 −-233Browse files

Showing the changes to sys/src/cmd/python/Python/fmod.c (1 of 3706 files). Show all

Unified · Split

sys/src/cmd/python/Python/fmod.c+27−0
@@ -0,0 +1,27 @@
1
2/* Portable fmod(x, y) implementation for systems that don't have it */
3
4#include "pyconfig.h"
5
6#include "pyport.h"
7#include <errno.h>
8
9double
10fmod(double x, double y)
11{
12 double i, f;
13
14 if (y == 0.0) {
15 errno = EDOM;
16 return 0.0;
17 }
18
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 */
21
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;
27}