]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Clarify that sulp expects a nonnegative input, but that +0.0 is fine.
authorMark Dickinson <dickinsm@gmail.com>
Wed, 13 Jan 2010 19:02:37 +0000 (19:02 +0000)
committerMark Dickinson <dickinsm@gmail.com>
Wed, 13 Jan 2010 19:02:37 +0000 (19:02 +0000)
Python/dtoa.c

index 504ad1f8cfff4e698e96b4c5c0bdbfe4d4316bdd..e953f09c01e7998cd91bcf1238c11b297b4aa4b0 100644 (file)
@@ -1130,11 +1130,11 @@ quorem(Bigint *b, Bigint *S)
     return q;
 }
 
-/* version of ulp(x) that takes bc.scale into account.
+/* sulp(x) is a version of ulp(x) that takes bc.scale into account.
 
-   Assuming that x is finite and nonzero, and x / 2^bc.scale is exactly
-   representable as a double, sulp(x) is equivalent to 2^bc.scale * ulp(x /
-   2^bc.scale). */
+   Assuming that x is finite and nonnegative (positive zero is fine
+   here) and x / 2^bc.scale is exactly representable as a double,
+   sulp(x) is equivalent to 2^bc.scale * ulp(x / 2^bc.scale). */
 
 static double
 sulp(U *x, BCinfo *bc)
@@ -1147,8 +1147,10 @@ sulp(U *x, BCinfo *bc)
         word1(&u) = 0;
         return u.d;
     }
-    else
+    else {
+        assert(word0(x) || word1(x)); /* x != 0.0 */
         return ulp(x);
+    }
 }
 
 /* The bigcomp function handles some hard cases for strtod, for inputs