Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 1abf1ca0e8b381485de4ed6dd2f84d3bf8398ef4
Ticket: 410043ffffffffffffffffffffffffffffffffff
"if" does not evaluate same as "expr"
User & Date: nobody on 2001-03-20 16:17:01
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed 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 changed to: "obsolete: 8.3"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "45. Parsing and Eval"
  10. title changed to: ""if" does not evaluate same as "expr""
  11. type changed to: "Bug"