diff Modules/structmodule.c @ 6551:bdd4cb2a83b5 legacy-trunk

Fix due to Bill Noon for problem discovered by Ken Manheimer: packing 0.0 as float or double would yield the representation for 1.0!
author Guido van Rossum <guido@python.org>
date Tue, 04 Nov 1997 17:12:33 +0000
parents 2c29b8982643
children 7629c4d985bc
line wrap: on
line diff
--- a/Modules/structmodule.c	Tue Nov 04 17:04:34 1997 +0000
+++ b/Modules/structmodule.c	Tue Nov 04 17:12:33 1997 +0000
@@ -167,7 +167,7 @@
 		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 @@
 		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 */
 	}