#1147 closed Bug (Fixed)
Comparison of numbers against strings gives unexpected results
| Reported by: | jchd | Owned by: | Valik |
|---|---|---|---|
| Milestone: | 3.3.7.20 | Component: | AutoIt |
| Version: | 3.3.1.1 | Severity: | None |
| Keywords: | comparison strings numbers | Cc: |
Description
The wording used in the helpfile, Datatypes section (when a string is "used" as a number) pushed me to try some tests whose results go against the common explanation repeatedly given: "if a number is compared to a string, the later is evaluated as Number(string)". In short, we have that:
(5 = Number("5abc")) returns True, but
(5 = "5abc") returns False !?!
("5abc" = 5) returns False !?! (just checking)
(0 > "5abc") returns False !?!
(1 > "5abc") returns True !?!
(5 > "5abc") returns True !?!
It _sounds_ like the current rules are something along those lines:
any string containing one or more non-(digit or minus) is evaluated as integer 0
Reals have other rules:
(5 = 5. ) returns True
(5 = '5.') returns False
(5. = '5.') returns False
Perhaps the behavior of comparison between strings and numerics should be clarified. Or Number() should convert the string before comparison, which could possibly break existing (doubtful) code.
I still don't know if this ticket really is a feature request, a documentation clarification request or a bug report.
Attachments (0)
Change History (9)
comment:1 by , 17 years ago
| Version: | 3.3.1.1 |
|---|
comment:2 by , 17 years ago
| Type: | Feature Request → Bug |
|---|---|
| Version: | → 3.3.1.1 |
This looks very much like a bug. I see some suspicious code that makes me think the implicit conversions aren't working right.
comment:3 by , 16 years ago
| Owner: | set to |
|---|---|
| Status: | new → assigned |
comment:4 by , 16 years ago
| Severity: | None → Blocking |
|---|
comment:5 by , 16 years ago
| Milestone: | → 3.3.1.4 |
|---|---|
| Resolution: | → Fixed |
| Status: | assigned → closed |
Fixed in version: 3.3.1.4
comment:6 by , 16 years ago
| Milestone: | 3.3.1.4 |
|---|---|
| Resolution: | Fixed |
| Status: | closed → reopened |
I'm reverting my change for the time being. The behavior will not be changed in 3.3.1.4.
comment:7 by , 16 years ago
| Severity: | Blocking → None |
|---|
Removing the blocking flag. This will not be fixed until later down the road.
comment:8 by , 14 years ago
| Milestone: | → Future Release |
|---|---|
| Resolution: | → Fixed |
| Status: | reopened → closed |
It seems like this was fixed at some point. Closing as such.
comment:9 by , 14 years ago
| Milestone: | Future Release → 3.3.7.20 |
|---|

Automatic ticket cleanup.