summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2008-04-20 18:30:05 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2008-04-20 18:30:05 (GMT)
commitc632301bd4ddbd1207f4c737c925411916faf8c0 (patch)
tree2d9ed4e28a39de7f6e3fa185345d2eb4196ac9b6
parent2cede399ec01cba5f6998401c24cd6c0c9042cac (diff)
downloadcpython-c632301bd4ddbd1207f4c737c925411916faf8c0.zip
cpython-c632301bd4ddbd1207f4c737c925411916faf8c0.tar.gz
cpython-c632301bd4ddbd1207f4c737c925411916faf8c0.tar.bz2
Even more fixes for alpha Tru64, this time for
the phase and polar methods.
-rw-r--r--Modules/cmathmodule.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/Modules/cmathmodule.c b/Modules/cmathmodule.c
index 347f88d..d6d1f27 100644
--- a/Modules/cmathmodule.c
+++ b/Modules/cmathmodule.c
@@ -264,7 +264,8 @@ c_atan(Py_complex z)
return r;
}
-/* Windows screws up atan2 for inf and nan */
+/* Windows screws up atan2 for inf and nan, and alpha Tru64 5.1 doesn't follow
+ C99 for atan2(0., 0.). */
static double
c_atan2(Py_complex z)
{
@@ -282,6 +283,14 @@ c_atan2(Py_complex z)
/* atan2(+-inf, x) == +-pi/2 for finite x */
return copysign(0.5*Py_MATH_PI, z.imag);
}
+ if (Py_IS_INFINITY(z.real) || z.imag == 0.) {
+ if (copysign(1., z.real) == 1.)
+ /* atan2(+-y, +inf) = atan2(+-0, +x) = +-0. */
+ return copysign(0., z.imag);
+ else
+ /* atan2(+-y, -inf) = atan2(+-0., -x) = +-pi. */
+ return copysign(Py_MATH_PI, z.imag);
+ }
return atan2(z.imag, z.real);
}