Opened on Aug 23, 2009 at 2:36:39 AM
Closed on Oct 28, 2011 at 9:40:06 PM
Last modified on Feb 9, 2012 at 3:16:44 PM
#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 , on Aug 23, 2009 at 4:00:01 AM
| Version: | 3.3.1.1 |
|---|
comment:2 by , on Aug 23, 2009 at 4:47:12 PM
| 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 , on Oct 16, 2009 at 8:45:01 AM
| Owner: | set to |
|---|---|
| Status: | new → assigned |
comment:4 by , on Oct 17, 2009 at 12:44:31 AM
| Severity: | None → Blocking |
|---|
comment:5 by , on Oct 21, 2009 at 6:02:48 PM
| Milestone: | → 3.3.1.4 |
|---|---|
| Resolution: | → Fixed |
| Status: | assigned → closed |
Fixed in version: 3.3.1.4
comment:6 by , on Oct 24, 2009 at 10:00:51 PM
| 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 , on Oct 25, 2009 at 4:51:12 PM
| Severity: | Blocking → None |
|---|
Removing the blocking flag. This will not be fixed until later down the road.
comment:8 by , on Oct 28, 2011 at 9:40:06 PM
| Milestone: | → Future Release |
|---|---|
| Resolution: | → Fixed |
| Status: | reopened → closed |
It seems like this was fixed at some point. Closing as such.
comment:9 by , on Feb 9, 2012 at 3:16:44 PM
| Milestone: | Future Release → 3.3.7.20 |
|---|

Automatic ticket cleanup.