[Python-checkins] r62420 - python/trunk/Modules/cmathmodule.c

mark.dickinson python-checkins at python.org
Sun Apr 20 20:30:05 CEST 2008


Author: mark.dickinson
Date: Sun Apr 20 20:30:05 2008
New Revision: 62420

Log:
Even more fixes for alpha Tru64, this time for
the phase and polar methods.


Modified:
   python/trunk/Modules/cmathmodule.c

Modified: python/trunk/Modules/cmathmodule.c
==============================================================================
--- python/trunk/Modules/cmathmodule.c	(original)
+++ python/trunk/Modules/cmathmodule.c	Sun Apr 20 20:30:05 2008
@@ -264,7 +264,8 @@
 	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 @@
 		/* 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);
 }
 


More information about the Python-checkins mailing list