Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 47773e6aad43d1f8145827bc3c3f08f09a149d5c
Ticket: ef5373e6fa0617ee02f201c6c8f41746678c5afb
expr, literal numeric values, and string comparisons
User & Date: pooryorick on 2016-10-03 22:17:53
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-wiki"
  4. comment changed to:
    The documentation for <code>expr</code> provides seven rules for operand
    syntax.  Of those, the value <code>0x12</code> matches rule 1, and only rule 1:
    "... a numeric value, either integer or floating-point".  Therefore,
    <code>0x12</code> is unambiguously a numeric value.  The string representation
    of <code>0x12</code> is <code>18</code>, as illustrated by the result of
    <code>[expr 0x12]</code>.  Furthermore, the documentation states that operands
    that are not numeric or boolean must be quoted.  It's well-accepted that only
    numeric operands can appear unquoted in an expression.  Finally, the
    documentation states that in order to compare a numeric operand to an operand
    that can't be interpreted as numeric, the string representation for the numeric
    operand is generated.  Consider
    
    <code><verbatim>
    expr {{0y} > 0x12}
    </verbatim></code>
    
    . Since <code>0x12<code> is numeric, and its string representation is
    <code>18</code>, the previous command should produce the same result as
    
    <code><verbatim>
    expr {{0y} > {18}}
    </verbatim></code>
    
    . However, this isn't the case.  The result of the first command is `1`, and
    the result of the second is `0`.
    
  5. foundin changed to: "8.5"
  6. is_private changed to: "0"
  7. login: "pooryorick"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "4403a7f74e8fccbce1943bdd674d5d936b16d5b8"
  10. resolution changed to: "None"
  11. severity changed to: "Minor"
  12. status changed to: "Open"
  13. submitter changed to: "pooryorick"
  14. subsystem changed to: "16. Commands A-H"
  15. title changed to:
    expr, literal numeric values, and string comparisons
    
  16. type changed to: "Bug"