Mercurial > cpython-lru_cache-weakref
annotate Python/fmod.c @ 20471:bbdc0abfbb13 legacy-trunk
SF patch #471852 (anonymous) notes that getattr(obj, name, default)
masks any exception, not just AttributeError. Fix this.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Tue, 16 Oct 2001 21:31:32 +0000 |
| parents | 2dea40e40d9d |
| children |
| rev | line source |
|---|---|
| 145 | 1 |
| 6 | 2 /* Portable fmod(x, y) implementation for systems that don't have it */ |
| 3 | |
|
18835
2dea40e40d9d
Patch #411138: Rename config.h to pyconfig.h. Closes bug #231774.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
4 #include "pyconfig.h" |
| 2434 | 5 |
|
13761
59f8cedcf049
merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13256
diff
changeset
|
6 #include "pyport.h" |
| 6 | 7 #include <errno.h> |
| 8 | |
| 9 double | |
| 2434 | 10 fmod(double x, double y) |
| 6 | 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 } |
