Artifacts Associated With Ticket ef5373e6fa0617ee
Ticket change [47773e6aad] (rid 149024) by pooryorick on 2016-10-03 22:17:53:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/x-fossil-wiki"
- 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`. - foundin initialized to: "8.5"
- is_private initialized to: "0"
- login: "pooryorick"
- priority initialized to: "5 Medium"
- private_contact initialized to: "4403a7f74e8fccbce1943bdd674d5d936b16d5b8"
- resolution initialized to: "None"
- severity initialized to: "Minor"
- status initialized to: "Open"
- submitter initialized to: "pooryorick"
- subsystem initialized to: "16. Commands A-H"
- title initialized to:
expr, literal numeric values, and string comparisons
- type initialized to: "Bug"
Ticket change [bc9c2c37e1] (rid 149035) by dgp on 2016-10-04 18:27:07:
- 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.
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [45376453e8] (rid 149106) by dkf on 2016-10-08 16:57:57:
- assignee changed to: "dgp"
- login: "dkf"
- mimetype: "text/plain"
Ticket change [38506fd9d4] (rid 149361) by dkf on 2016-10-30 17:40:11:
- 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>. - login: "dkf"
- mimetype: "text/plain"
- comment changed to:
Ticket change [a171bcb9e7] (rid 149366) by oehhar on 2016-10-31 17:34:20:
- closedate changed to: "2457693.23218128"
- closer changed to: "oehhar"
- 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
- login: "oehhar"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Rejected"
- status changed to: "Closed"
- username: "oehhar"
Ticket change [13049c5afb] (rid 234239) by pooryorick on 2024-10-11 18:36:41:
- closedate changed to: "2460595.27548389"
- closer changed to: "pooryorick"
- 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.
- login: "pooryorick"
- mimetype: "text/x-fossil-wiki"
- private_contact changed to: "5d4b6538b2536427c4ee4dd0ec7495de74567d31"
- resolution changed to: "Invalid"