Mercurial > cpython-lru_cache-weakref
annotate Python/fmod.c @ 13658:f79434ee41fa legacy-trunk
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
declarations yet, those come later.
| author | Thomas Wouters <thomas@python.org> |
|---|---|
| date | Sat, 22 Jul 2000 18:47:25 +0000 |
| parents | 87ee82e5c56d |
| children | 59f8cedcf049 |
| rev | line source |
|---|---|
| 145 | 1 /*********************************************************** |
|
13255
916fb024ce94
Change copyright notice.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
2 Copyright (c) 2000, BeOpen.com. |
|
916fb024ce94
Change copyright notice.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
3 Copyright (c) 1995-2000, Corporation for National Research Initiatives. |
|
916fb024ce94
Change copyright notice.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
4 Copyright (c) 1990-1995, Stichting Mathematisch Centrum. |
|
916fb024ce94
Change copyright notice.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
5 All rights reserved. |
| 145 | 6 |
|
13255
916fb024ce94
Change copyright notice.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
7 See the file "Misc/COPYRIGHT" for information on usage and |
|
916fb024ce94
Change copyright notice.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
8 redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 145 | 9 ******************************************************************/ |
| 10 | |
| 6 | 11 /* Portable fmod(x, y) implementation for systems that don't have it */ |
| 12 | |
| 2434 | 13 #include "config.h" |
| 14 | |
| 15 #include "mymath.h" | |
| 6 | 16 #include <errno.h> |
| 17 | |
| 18 double | |
| 2434 | 19 fmod(double x, double y) |
| 6 | 20 { |
| 21 double i, f; | |
| 22 | |
| 23 if (y == 0.0) { | |
| 24 errno = EDOM; | |
| 25 return 0.0; | |
| 26 } | |
| 27 | |
| 28 /* return f such that x = i*y + f for some integer i | |
| 29 such that |f| < |y| and f has the same sign as x */ | |
| 30 | |
| 31 i = floor(x/y); | |
| 32 f = x - i*y; | |
| 33 if ((x < 0.0) != (y < 0.0)) | |
| 34 f = f-y; | |
| 35 return f; | |
| 36 } |
