[Python-Dev] Nondeterministic long-to-float coercion
"Martin v. Löwis"
martin at v.loewis.de
Thu Oct 19 23:20:28 CEST 2006
Raymond Hettinger schrieb:
> My colleague got an odd result today that is reproducible on his build
> of Python (RedHat's distribution of Py2.4.2) but not any other builds
> I've checked (including an Ubuntu Py2.4.2 built with a later version of
> GCC). I hypothesized that this was a bug in the underlying GCC
> libraries, but the magnitude of the error is so large that that seems
> implausible. Does anyone have a clue what is going-on?
I'd say it's memory corruption. Look:
r=array.array("d",[-194000000.0, -193995904.0, -193994880.0]).tostring()
print map(ord,r[0:8])
print map(ord,r[8:16])
print map(ord,r[16:24])
gives
[0, 0, 0, 0, 105, 32, 167, 193]
[0, 0, 0, 0, 73, 32, 167, 193]
[0, 0, 0, 0, 65, 32, 167, 193]
It's only one byte that changes, and then that in only two bits (2**3
and 2**5). Could be faulty hardware, too.
Regards,
Martin
More information about the Python-Dev
mailing list