Skip to content
Tcl Source Code History Of Ticket 218443ffffffffff
Login

History Of Ticket 218443ffffffffff

Artifacts Associated With Ticket 218443ffffffffff

  1. Ticket change [33841e7bf8] (rid 106606) by nobody on 2000-10-26 00:57:39:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      OriginalBugID: 6295 Bug
      Version: 8.3.2
      SubmitDate: '2000-09-21'
      LastModified: '2000-10-18'
      Severity: MED
      Status: Closed
      Submitter: techsupp
      ChangedBy: ericm
      OS: All Windows
      OSVersion: Windows NT 4.0
      Machine: Dell Dimension P200
      FixedDate: '2000-10-25'
      ClosedDate: '2000-10-18'
      
      
      Name:
      Jon Hilbert
      
      ReproducibleScript:
      for {set i 0} {$i < 10} {incr i} {set a($i) "0.10"}
      set total 0
      for {set i 0} {$i < 10} {incr i} {set total [expr {$total + $a($i)}]}
      if {$total != 1.0} {puts "what? why doesn't $total == 1.0 ?"}
      if {[expr $total] == 1.0} {puts "but \[expr $total] == 1.0 ?"}
      info patchlevel
      
      ObservedBehavior:
      as the script shows, the results of "if {$total != 1.0}" are not the same as "if {[expr $total] != 1.0}". I think they should be.
      
      
      
      Floating-point comparisons are notoriously unreliable.  Likely what you are hitting here is an artifact of the limitations of floating-point arithmetic inherent in all computer platforms.
      
      If you must perform floating-point equality comparisons, you are better off with something like:
      
      set tolerance 0.001
      if { 1.0 - $tolerance <= $total && $total <= 1.0 + $tolerance } {
      ...
      }
      
      That is, allow for a "slush factor" in the comparison by testing that the value is "tolerably close" to the expected value.
      
         Eric Melski                            The Other Tcl Guy
         ericm at ajubasolutions.com            Ajuba Solutions
      
      -- 10/18/2000 ericm
      
      
      
    4. foundin initialized to: "obsolete: 8.3.2"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "nobody"
    9. subsystem initialized to: "69. Other"
    10. title initialized to:
      an if expression comparing a computed floating point value w
      
    11. type initialized to: "Bug"
  2. Ticket change [400b04fe04] (rid 121559) by welch on 2000-10-26 08:22:16:

    1. closedate changed to: "2000-10-26T01:22:16"
    2. closer changed to: "welch"
    3. priority changed to: "2"
    4. resolution changed to: "Fixed"
    5. status changed to: "Closed"
  3. Ticket change [9bb8923d96] (rid 111174) by dgp on 2001-04-20 02:41:06:

    1. closedate changed to: "2001-04-19T19:41:06"
    2. closer changed to: "dgp"
    3. resolution changed to: "Invalid"
    4. subsystem changed to: "16. Commands A-H"