Artifacts Associated With Ticket 2828631
Ticket change [c617ff3d67] (rid 121706) by israelt on 2009-07-28 21:15:15:
- assignee initialized to: "dgp"
- cmimetype initialized to: "text/plain"
- comment initialized to:
In Tcl 8.5.4: % expr 0.8 - 0.35 0.450000000000007 %expr 0.6 - 0.15 0.449999999999996 In Tcl 8.4: % expr 0.8 - 0.35 0.45 %expr 0.6 - 0.15 0.45 OS is Linux. So scripts that used to work in 8.4 fail in 8.5.4 for our customers. Is there a fix for this issue? workaround? Thanks, Israel Taller
- foundin initialized to: "obsolete: 8.5.4"
- is_private initialized to: "0"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "israelt"
- subsystem initialized to: "48. Number Handling"
- title initialized to: "expr return value"
- type initialized to: "Bug"
Ticket change [7fa455b64f] (rid 97596) by dkf on 2009-07-29 04:49:34:
- icomment:
The issue is that 8.5 uses different rounding by default when converting doubles to strings, not that 8.5 has suddenly become less accurate (the deep problem is that 0.35, 0.45 and 0.15 do not have finite expansions in IEEE binary arithmetic). Compare these two logs and notice that the values are actually the same except for the different number of decimal places. % info patch 8.4.7 % expr 0.8 - 0.35 0.45 % expr 0.6 - 0.15 0.45 % expr 0.8 - 0.35 - 0.45 5.55111512313e-17 % expr 0.6 - 0.15 - 0.45 -5.55111512313e-17 % info patch 8.5.2 % expr 0.8 - 0.35 - 0.45 5.551115123125783e-17 % expr 0.6 - 0.15 - 0.45 -5.551115123125783e-17 I'll let dgp suggest a workaround for you.
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [da29f8ac63] (rid 107730) by dgp on 2009-07-29 19:30:19:
- closedate changed to: "2009-07-29T12:30:19"
- closer changed to: "dgp"
- icomment:
allow_comments - 1 The usual reply is why do you care? The 8.5 formats are actually more accurate, so if you are doing calculations with the values they should be better - a bug fix. If the issue is something pretty for display, that's what [format] is for. More from the release notes of Tcl 8.5.0, http://sf.net/project/shownotes.php?group_id=10894&release_id=562516 : " * When floating point values are converted to a string representation, the conversion is no longer governed by a default value of 12 for $::tcl_precision. The default value is now 0, meaning the shortest string representation that when parsed produces precisely the same floating point value. Some scripts that display floating point values may begin to see displays like "1.9999999999999998" where "2.0" had been displayed before. Revise the script to explicitly [format] values as desired. As a last resort, [set ::tcl_precision 12] will restore compatibility within the current thread, but be aware this will also resurrect bugs that the change has fixed."
- login: "dgp"
- mimetype: "text/plain"
- resolution changed to: "Invalid"
- status changed to: "Closed"
- username: "dgp"