Commits

Frank Wierzbicki committed 0ad7704

Add is_integer to float and handle pow NaN better.

  • Participants
  • Parent commits e3f1125

Comments (0)

Files changed (1)

src/org/python/core/PyFloat.java

             return new PyFloat(0);
         }
 
-        if ((value == 1.0) && Double.isNaN(iw)) {
-            return new PyFloat(1.0);
+        if (Double.isNaN(iw)) {
+            if (value == 1.0) {
+                return new PyFloat(1.0);
+            } else {
+                return new PyFloat(Double.NaN);
+            }
         }
 
         if (value < 0 && iw != Math.floor(iw)) {
         return this;
     }
 
+    public boolean is_integer() {
+        return float_is_integer();
+    }
+
+    @ExposedMethod(doc = BuiltinDocs.float_is_integer_doc)
+    final boolean float_is_integer() {
+        if (Double.isInfinite(value)) {
+            return false; 
+        }
+        return Math.floor(value) == value;
+    }
+
     @Override
     public PyComplex __complex__() {
         return new PyComplex(getValue(), 0.);