Mercurial > cpython-lru_cache-weakref
annotate Python/hypot.c @ 44156:fb84bd9500a4
Remove special-casing of integer operations, to stop
using PyInt_CheckExact.
| author | Martin v. Löwis <martin@v.loewis.de> |
|---|---|
| date | Tue, 04 Dec 2007 20:34:12 +0000 |
| parents | 7bc4cc972b0b |
| children | ef859cd754a7 |
| rev | line source |
|---|---|
| 4176 | 1 /* hypot() replacement */ |
| 2 | |
|
43829
7bc4cc972b0b
Merged revisions 58939-58946 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
18835
diff
changeset
|
3 #include "Python.h" |
| 4176 | 4 |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
4176
diff
changeset
|
5 double hypot(double x, double y) |
| 4176 | 6 { |
| 7 double yx; | |
| 8 | |
| 9 x = fabs(x); | |
| 10 y = fabs(y); | |
| 11 if (x < y) { | |
| 12 double temp = x; | |
| 13 x = y; | |
| 14 y = temp; | |
| 15 } | |
| 16 if (x == 0.) | |
| 17 return 0.; | |
| 18 else { | |
| 19 yx = y/x; | |
| 20 return x*sqrt(1.+yx*yx); | |
| 21 } | |
| 22 } |
