diff Objects/floatobject.c @ 38293:688f25757104 legacy-trunk

Added a new macro, Py_IS_FINITE(X). On windows there is an intrinsic for this and it is more efficient than to use !Py_IS_INFINITE(X) && !Py_IS_NAN(X). No change on other platforms
author Kristján Valur Jónsson <kristjan@ccpgames.com>
date Thu, 25 May 2006 15:53:30 +0000
parents 20cb13bdf1f0
children d5fa4afd6620
line wrap: on
line diff
--- a/Objects/floatobject.c	Thu May 25 15:49:45 2006 +0000
+++ b/Objects/floatobject.c	Thu May 25 15:53:30 2006 +0000
@@ -384,7 +384,7 @@
 	if (PyFloat_Check(w))
 		j = PyFloat_AS_DOUBLE(w);
 
-	else if (Py_IS_INFINITY(i) || Py_IS_NAN(i)) {
+	else if (!Py_IS_FINITE(i)) {
 		if (PyInt_Check(w) || PyLong_Check(w))
 			/* If i is an infinity, its magnitude exceeds any
 			 * finite integer, so it doesn't matter which int we
@@ -802,10 +802,7 @@
 		 * bug; we let that slide in math.pow() (which currently
 		 * reflects all platform accidents), but not for Python's **.
 		 */
-		 if (iv == -1.0 && !Py_IS_INFINITY(iw) && iw == iw) {
-		 	/* XXX the "iw == iw" was to weed out NaNs.  This
-		 	 * XXX doesn't actually work on all platforms.
-		 	 */
+		 if (iv == -1.0 && Py_IS_FINITE(iw)) {
 		 	/* Return 1 if iw is even, -1 if iw is odd; there's
 		 	 * no guarantee that any C integral type is big
 		 	 * enough to hold iw, so we have to check this