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

History Of Ticket 410043ffffffffff

Artifacts Associated With Ticket 410043ffffffffff

  1. Ticket change [1abf1ca0e8] (rid 123035) by nobody on 2001-03-20 16:17:01:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      The following script produces strange output.
      
      Script:
      #-----------------------------------------------
      set vmin 1.3
      set vmax 1.7
      set idx  4
      set incr 0.1
      
      set newval [expr {$vmin+int($idx)*$incr}]
      
      if { $newval > $vmax } {
          puts "Bare 'if' says $newval > $vmax"
      } else {
          puts "Bare 'if' says $newval <= $vmax"
      }
      
      if { [expr $newval > $vmax] } {
          puts "'if' with expr says $newval > $vmax"
      } else {
          puts "'if' with expr says $newval <= $vmax"
      }
      #-----------------------------------------------
      
      Output:
      Bare 'if' says 1.7 > 1.7
      'if' with expr says 1.7 <= 1.7
      
      As you see, the "if" command returns a different answer
      depending on whether or not you use expr.
      
    4. foundin initialized to: "obsolete: 8.3"
    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: "45. Parsing and Eval"
    10. title initialized to: ""if" does not evaluate same as "expr""
    11. type initialized to: "Bug"
  2. Ticket change [e239a82c84] (rid 87586) by nobody on 2001-03-20 23:23:36:

    1. icomment:
      Logged In: NO 
      
      The problem seems to be that the arguments to [expr] aren't braced.  I added:
      
      if { [expr {$newval > $vmax}] } {
          puts "'if' with braced expr says $newval > $vmax"
      } else {
          puts "'if' with braced expr says $newval <= $vmax"
      }
      
      and it agreed with the raw [if].  I imagine this has to do with shimmering but that's a guess.  You ought to 
      brace [expr] arguments for performance anyway so this doesn't seem like a real issue.
      
      -- Chris Nelson ([email protected]), who can't manage to log into SorceForge reliably
      
      
    2. login: "nobody"
    3. mimetype: "text/plain"
    4. username: "nobody"
  3. Ticket change [2c97a15461] (rid 118929) by dkf on 2001-03-20 23:43:47:

    1. closedate changed to: "2001-03-20T16:43:47"
    2. closer changed to: "dkf"
    3. icomment:
      Logged In: YES 
      user_id=79902
      
      This problem (a known feature of Tcl that is unlikely to
      ever be altered for a host of deep reasons) stems from the
      fact that 0.1 is not a precisely representable floating
      point number and that arguments to [expr] are [concat]enated
      before evaluation. Rerun the script with tcl_precision set
      to 17, or with the expression to pass to [expr] in {braces},
      and you'll get agreement between the "bare if" and the "if
      with expr".
      
      If this matters very much, use fixed-point arithmetic
      instead.
      
      
    4. login: "dkf"
    5. mimetype: "text/plain"
    6. resolution changed to: "Invalid"
    7. status changed to: "Closed"
    8. title changed to: ""if" does not evaluate same as "expr""
    9. username: "dkf"