[Python-Dev] Nondeterministic long-to-float coercion
Facundo Batista
facundobatista at gmail.com
Thu Oct 19 23:24:46 CEST 2006
2006/10/19, Raymond Hettinger <rhettinger at ewtllc.com>:
> 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
> ...
> >>> set(-19400000000 * (1/100.0) for i in range(10000))
> set([-194000000.0, -193995904.0, -193994880.0])
I neither can reproduce it in my Ubuntu, but analyzing the problem...
what about this?:
d = {}
for i in range(10000):
val = -19400000000 * (1/100.0)
d[val] = d.get(val, 0) + 1
or
d = {}
for i in range(10000):
val = -19400000000 * (1/100.0)
d.setdefault(val, []).append(i)
I think that is interesting to know,,,
- if in these structures the problem still happens...
- how many values go for each key, and which values.
Regards,
--
. Facundo
Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/
More information about the Python-Dev
mailing list