diff options
author | Guido van Rossum <guido@python.org> | 1996-01-12 01:39:11 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1996-01-12 01:39:11 (GMT) |
commit | 32062686922e7df4869a371acf8ee84bd387fd89 (patch) | |
tree | 326f7c999150d106de6bcd55efec4e6d34806e5f /Modules/mathmodule.c | |
parent | b123691384fefed75ccc71fddb028e163fcaa6c7 (diff) | |
download | cpython-32062686922e7df4869a371acf8ee84bd387fd89.zip cpython-32062686922e7df4869a371acf8ee84bd387fd89.tar.gz cpython-32062686922e7df4869a371acf8ee84bd387fd89.tar.bz2 |
added default hypot() implementation
Diffstat (limited to 'Modules/mathmodule.c')
-rw-r--r-- | Modules/mathmodule.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c index 9cff9e0..4e704bf 100644 --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -42,6 +42,27 @@ extern double modf PROTO((double, double *)); #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_exp, exp) 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 @@ static struct methodlist math_methods[] = { {"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}, |