Modify

Opened 17 years ago

Closed 14 years ago

Last modified 14 years ago

#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 TicketCleanup, 17 years ago

Version: 3.3.1.1

Automatic ticket cleanup.

comment:2 by Valik, 17 years ago

Type: Feature RequestBug
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 J-Paul Mesnage, 16 years ago

Owner: set to Valik
Status: newassigned

comment:4 by Valik, 16 years ago

Severity: NoneBlocking

comment:5 by Valik, 16 years ago

Milestone: 3.3.1.4
Resolution: Fixed
Status: assignedclosed

Fixed in version: 3.3.1.4

comment:6 by Valik, 16 years ago

Milestone: 3.3.1.4
Resolution: Fixed
Status: closedreopened

I'm reverting my change for the time being. The behavior will not be changed in 3.3.1.4.

comment:7 by Valik, 16 years ago

Severity: BlockingNone

Removing the blocking flag. This will not be fixed until later down the road.

comment:8 by Valik, 14 years ago

Milestone: Future Release
Resolution: Fixed
Status: reopenedclosed

It seems like this was fixed at some point. Closing as such.

comment:9 by J-Paul Mesnage, 14 years ago

Milestone: Future Release3.3.7.20

Modify Ticket

Action
as closed The owner will remain Valik.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.