Skip to content
Tcl Source Code History Of Ticket ef5373e6fa0617ee
Login

History Of Ticket ef5373e6fa0617ee

Artifacts Associated With Ticket ef5373e6fa0617ee

  1. Ticket change [47773e6aad] (rid 149024) by pooryorick on 2016-10-03 22:17:53:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-wiki"
    4. comment initialized 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 initialized to: "8.5"
    6. is_private initialized to: "0"
    7. login: "pooryorick"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "4403a7f74e8fccbce1943bdd674d5d936b16d5b8"
    10. resolution initialized to: "None"
    11. severity initialized to: "Minor"
    12. status initialized to: "Open"
    13. submitter initialized to: "pooryorick"
    14. subsystem initialized to: "16. Commands A-H"
    15. title initialized to:
      expr, literal numeric values, and string comparisons
      
    16. type initialized to: "Bug"
  2. Ticket change [bc9c2c37e1] (rid 149035) by dgp on 2016-10-04 18:27:07:

    1. icomment:
      
      Everything is a string.
      
      The string value of 0x12 is 0x12.
      
      Where the documentation appears to suggest
      otherwise, it is in error and needs 
      correction and clarification.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  3. Ticket change [45376453e8] (rid 149106) by dkf on 2016-10-08 16:57:57:

    1. assignee changed to: "dgp"
    2. login: "dkf"
    3. mimetype: "text/plain"
  4. Ticket change [38506fd9d4] (rid 149361) by dkf on 2016-10-30 17:40:11:

    1. 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:
      "<i>... a numeric value, either integer or floating-point</i>".  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 <tt>1</tt>, and
      the result of the second is <tt>0</tt>.
      
    2. login: "dkf"
    3. mimetype: "text/plain"
  5. Ticket change [a171bcb9e7] (rid 149366) by oehhar on 2016-10-31 17:34:20:

    1. closedate changed to: "2457693.23218128"
    2. closer changed to: "oehhar"
    3. icomment:
      The issue of the argumentation is, that the string representation of 0x12 is 0x12 and not 18. "18" is the result of a conversion to decimal 0x 0x12.
      
      As a consequence, a comparison with the string "0y" once results in true, once in false which is correct IMHO.
      
      Thank you,
      Harald
      
    4. login: "oehhar"
    5. mimetype: "text/x-fossil-wiki"
    6. resolution changed to: "Rejected"
    7. status changed to: "Closed"
    8. username: "oehhar"
  6. Ticket change [13049c5afb] (rid 234239) by pooryorick on 2024-10-11 18:36:41:

    1. closedate changed to: "2460595.27548389"
    2. closer changed to: "pooryorick"
    3. icomment:
      The real answer here is that if [expr] *would* interpret 0x12 as a number if the operation made sense with a numeric operand, but because the other operand is a string, not a number, the only sensible thing that remains is to treat 0x12 as a string.  In fact in both of the given examples, string comparison, not numeric comparison is performed: 18 is also interpreted as a string, not a number.
      
    4. login: "pooryorick"
    5. mimetype: "text/x-fossil-wiki"
    6. private_contact changed to: "5d4b6538b2536427c4ee4dd0ec7495de74567d31"
    7. resolution changed to: "Invalid"