Mercurial > cpython-lru_cache-weakref
annotate Python/hypot.c @ 68231:5fd74354d73b 2.0
Close 2.0 branch.
| author | Georg Brandl <georg@python.org> |
|---|---|
| date | Sat, 05 Mar 2011 14:54:19 +0100 |
| parents | 59f8cedcf049 |
| children | 2dea40e40d9d |
| rev | line source |
|---|---|
| 4176 | 1 /* hypot() replacement */ |
| 2 | |
| 3 #include "config.h" | |
|
13761
59f8cedcf049
merge Include/my*.h into Include/pyport.h
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13658
diff
changeset
|
4 #include "pyport.h" |
| 4176 | 5 |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
4176
diff
changeset
|
6 double hypot(double x, double y) |
| 4176 | 7 { |
| 8 double yx; | |
| 9 | |
| 10 x = fabs(x); | |
| 11 y = fabs(y); | |
| 12 if (x < y) { | |
| 13 double temp = x; | |
| 14 x = y; | |
| 15 y = temp; | |
| 16 } | |
| 17 if (x == 0.) | |
| 18 return 0.; | |
| 19 else { | |
| 20 yx = y/x; | |
| 21 return x*sqrt(1.+yx*yx); | |
| 22 } | |
| 23 } |
