Mercurial > cpython-lru_cache-weakref
diff Modules/structmodule.c @ 4859:ab461c762559 legacy-trunk
Oops -- unpack float/double didn't do the right thing if e==0.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Thu, 02 Jan 1997 22:31:07 +0000 |
| parents | 198989ee36d5 |
| children | 69ca5e3ccc6d |
line wrap: on
line diff
--- a/Modules/structmodule.c Thu Jan 02 22:21:36 1997 +0000 +++ b/Modules/structmodule.c Thu Jan 02 22:31:07 1997 +0000 @@ -402,8 +402,13 @@ x = (double)f / 8388608.0; /* XXX This sadly ignores Inf/NaN issues */ - if (e != 0) - x = ldexp(1.0 + x, e - 127); + if (e == 0) + e = -126; + else { + x += 1.0; + e -= 127; + } + x = ldexp(x, e); if (s) x = -x; @@ -459,8 +464,13 @@ x /= 268435456.0; /* 2**28 */ /* XXX This sadly ignores Inf/NaN */ - if (e != 0) - x = ldexp(1.0 + x, e - 1023); + if (e == 0) + e = -1022; + else { + x += 1.0; + e -= 1023; + } + x = ldexp(x, e); if (s) x = -x;
