summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-11-04 17:12:33 (GMT)
committerGuido van Rossum <guido@python.org>1997-11-04 17:12:33 (GMT)
commit8f3c812e22d1fc2a70c1f1c2b56262553e8d9c34 (patch)
tree5510db473cd9f0f0fbf429aab3e7afb08893d68a /Modules
parent25c649fdf2e9326fd897ac9707d5041e151a8161 (diff)
downloadcpython-8f3c812e22d1fc2a70c1f1c2b56262553e8d9c34.zip
cpython-8f3c812e22d1fc2a70c1f1c2b56262553e8d9c34.tar.gz
cpython-8f3c812e22d1fc2a70c1f1c2b56262553e8d9c34.tar.bz2
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!
Diffstat (limited to 'Modules')
-rw-r--r--Modules/structmodule.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Modules/structmodule.c b/Modules/structmodule.c
index 4b01f4b..9b39919 100644
--- a/Modules/structmodule.c
+++ b/Modules/structmodule.c
@@ -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 */
}