Mercurial > cpython-lru_cache-weakref
annotate Python/fmod.c @ 13255:916fb024ce94 legacy-trunk
Change copyright notice.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Fri, 30 Jun 2000 23:50:40 +0000 |
| parents | 65d2d8e67da3 |
| children | 87ee82e5c56d |
| rev | line source |
|---|---|
| 145 | 1 /*********************************************************** |
|
2062
d0d0a69b5ca3
Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents:
1848
diff
changeset
|
2 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, |
|
d0d0a69b5ca3
Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents:
1848
diff
changeset
|
3 The Netherlands. |
| 145 | 4 |
| 5 All Rights Reserved | |
| 6 | |
|
13255
916fb024ce94
Change copyright notice.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
7 Copyright (c) 2000, BeOpen.com. |
|
916fb024ce94
Change copyright notice.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
8 Copyright (c) 1995-2000, Corporation for National Research Initiatives. |
|
916fb024ce94
Change copyright notice.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
9 Copyright (c) 1990-1995, Stichting Mathematisch Centrum. |
|
916fb024ce94
Change copyright notice.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
10 All rights reserved. |
| 145 | 11 |
|
13255
916fb024ce94
Change copyright notice.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
12 See the file "Misc/COPYRIGHT" for information on usage and |
|
916fb024ce94
Change copyright notice.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
13 redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 145 | 14 |
| 15 ******************************************************************/ | |
| 16 | |
| 6 | 17 /* Portable fmod(x, y) implementation for systems that don't have it */ |
| 18 | |
| 2434 | 19 #include "config.h" |
| 20 | |
| 21 #include "mymath.h" | |
| 6 | 22 #include <errno.h> |
| 23 | |
| 24 double | |
| 2434 | 25 fmod(double x, double y) |
| 6 | 26 { |
| 27 double i, f; | |
| 28 | |
| 29 if (y == 0.0) { | |
| 30 errno = EDOM; | |
| 31 return 0.0; | |
| 32 } | |
| 33 | |
| 34 /* return f such that x = i*y + f for some integer i | |
| 35 such that |f| < |y| and f has the same sign as x */ | |
| 36 | |
| 37 i = floor(x/y); | |
| 38 f = x - i*y; | |
| 39 if ((x < 0.0) != (y < 0.0)) | |
| 40 f = f-y; | |
| 41 return f; | |
| 42 } |
