]> granicus.if.org Git - python/commitdiff
Fix due to Bill Noon for problem discovered by Ken Manheimer: packing
authorGuido van Rossum <guido@python.org>
Tue, 4 Nov 1997 17:12:33 +0000 (17:12 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 4 Nov 1997 17:12:33 +0000 (17:12 +0000)
0.0 as float or double would yield the representation for 1.0!

Modules/structmodule.c

index 4b01f4bc2dc4da2ccb0790589872378eb73bbe9d..9b39919812e0e31f0aa0ea8b8723c8f6f2886426 100644 (file)
@@ -167,7 +167,7 @@ pack_float(x, p, incr)
                f = ldexp(f, 126 + e);
                e = 0;
        }
-       else {
+       else if (!(e == 0 && f == 0.0)) {
                e += 127;
                f -= 1.0; /* Get rid of leading 1 */
        }
@@ -239,7 +239,7 @@ pack_double(x, p, incr)
                f = ldexp(f, 1022 + e);
                e = 0;
        }
-       else {
+       else if (!(e == 0 && f == 0.0)) {
                e += 1023;
                f -= 1.0; /* Get rid of leading 1 */
        }