Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 5461560ec6ad9049876a70c1e786f49b04f240e9342504a483778ab7a3086ad7
Ticket: aa69bce71e214872af462de3a3050a46eec61385
expr comparison operator result does not follow the documentation
User & Date: anonymous on 2024-03-11 21:26:09
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-plain"
  4. comment changed to:
    I wanted to know if the 'expr' command when using the < operator compares its arguments as numbers or as strings. So I checked the documentation for expr. This is what it says:
    
    >> These operators may be applied to strings as well as numeric operands, in which case string comparison is used. <<
    
    https://tcl.tk/man/tcl/TclCmd/expr.htm#M12
    
    From this, I expect that I can compare two string, or I can compare two numbers, both will be ok for the operator. It should always compare as strings - as it says that strig comparison is used.
    
    But the implementation does not follow it
    
    % expr {12<2}
    0
    % expr {"12"<"2"}
    0
    
    When compared as strings the first should be smaller than the second. The result should be 1.
    
    The string comparison should be like this:
    
    % string compare 12 2
    -1
    
    I.e. the first string is less than the second.
    
    Or maybe the documentation is wrong?
    
  5. foundin changed to: "8.6"
  6. is_private changed to: "0"
  7. login: "anonymous"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "eb1592a11067c658ae62686070571429a9282829"
  10. resolution changed to: "None"
  11. severity changed to: "Minor"
  12. status changed to: "Open"
  13. submitter changed to: "anonymous"
  14. subsystem changed to: "16. Commands A-H"
  15. title changed to:
    expr comparison operator result does not follow the documentation
    
  16. type changed to: "Bug"