New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tkinter precision loss for doubles #38303
Comments
DoubleVar.set() (I think) goes thru PyObject_Str(), >>> import Tkinter
>>> import math
>>> x = Tkinter.DoubleVar(Tkinter.Tk())
>>> x.set(math.pi)
>>> x.get()
3.1415926535900001 # not good
>>> math.pi
3.1415926535897931 # original precision
>>> eval(str(math.pi))
3.1415926535900001 # reproduces Tk result
>>> Reported on c.l.py. Guido says you may know how to |
Logged In: YES If a proper fix using Tcl float/double objects doesn't work |
Logged In: YES I have now fixed this for _tkinter.c 1.154, by passing all This causes slight semantic changes (like the one being >>> y=Tkinter.StringVar(Tkinter.Tk())
>>> y.set(3.14)
>>> y.get()
3.1400000000000001 So a StringVar may not return a string anymore if .set did |
Logged In: YES Thanks! Re StringVar: I think StringVar should coerce the result to BTW there are a few places in Tkinter docstrings that |
Logged In: YES In Tkinter.py 1.172, StringVars now always returns strings |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: