| Ticket UUID: | ef5373e6fa0617ee02f201c6c8f41746678c5afb | |||
| Title: | expr, literal numeric values, and string comparisons | |||
| Type: | Bug | Version: | 8.5 | |
| Submitter: | pooryorick | Created on: | 2016-10-03 22:17:53 | |
| Subsystem: | 16. Commands A-H | Assigned To: | dgp | |
| Priority: | 5 Medium | Severity: | Minor | |
| Status: | Closed | Last Modified: | 2024-10-11 18:36:41 | |
| Resolution: | Invalid | Closed By: | pooryorick | |
| Closed on: | 2024-10-11 18:36:41 | |||
| Description: |
The documentation for
. Since
. However, this isn't the case. The result of the first command is 1, and the result of the second is 0. | |||
| User Comments: |
pooryorick added on 2024-10-11 18:36:41:
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. oehhar added on 2016-10-31 17:34:20: 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 dgp added on 2016-10-04 18:27:07: 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. | |||