Mercurial > cpython-lru_cache-weakref
diff Modules/mathmodule.c @ 3339:16cb0473224c legacy-trunk
added default hypot() implementation
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Fri, 12 Jan 1996 01:39:11 +0000 |
| parents | 686f4bfb4da6 |
| children | e07597389d64 |
line wrap: on
line diff
--- a/Modules/mathmodule.c Fri Jan 12 01:38:49 1996 +0000 +++ b/Modules/mathmodule.c Fri Jan 12 01:39:11 1996 +0000 @@ -42,6 +42,27 @@ #if defined(HAVE_HYPOT) && !defined(NeXT) extern double hypot PROTO((double, double)); +#else +double hypot(x,y) + double x; + double y; +{ + double yx; + + x = fabs(x); + y = fabs(y); + if (x < y) { + double temp = x; + x = y; + y = temp; + } + if (x == 0.) + return 0.; + else { + yx = y/x; + return x*sqrt(1.+yx*yx); + } +} #endif #ifdef i860 @@ -124,9 +145,7 @@ FUNC1(math_fabs, fabs) FUNC1(math_floor, floor) FUNC2(math_fmod, fmod) -#ifdef HAVE_HYPOT FUNC2(math_hypot, hypot) -#endif FUNC1(math_log, log) FUNC1(math_log10, log10) #ifdef MPW_3_1 /* This hack is needed for MPW 3.1 but not for 3.2 ... */ @@ -213,9 +232,7 @@ {"floor", math_floor}, {"fmod", math_fmod}, {"frexp", math_frexp}, -#ifdef HAVE_HYPOT {"hypot", math_hypot}, -#endif {"ldexp", math_ldexp}, {"log", math_log}, {"log10", math_log10},
