Loss of precision / data corruption with Tkinter.DoubleVar ?!
Lonnie Princehouse
fnord at u.washington.edu
Fri Apr 11 14:07:33 EDT 2003
Greetings,
I stumbled across this curiosity yesterday:
>>> x = 0.33333333333333098
>>> x
0.33333333333333098
>>> import Tkinter
>>> y = Tkinter.DoubleVar(Tkinter.Tk())
>>> y.set(x)
>>> y.get()
0.33333333333300003
What the....?
Sure, it's only on the order of 10e-13 delta,
but why is there any difference at all??
I hit this because at some point I was trying to do:
y.set(x)
.
.
.
if y.get() == x:
...
and of course it wasn't working properly!
I have tried this on Python 2.2 for Win32 and Linux/x86
-Lonnie Princehouse
More information about the Python-list
mailing list