Modify

Opened 15 years ago

Closed 13 years ago

Last modified 13 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 Changed 15 years ago by TicketCleanup

  • Version 3.3.1.1 deleted

Automatic ticket cleanup.

comment:2 Changed 15 years ago by Valik

  • Type changed from Feature Request to Bug
  • Version set to 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 Changed 15 years ago by Jpm

  • Owner set to Valik
  • Status changed from new to assigned

comment:4 Changed 15 years ago by Valik

  • Severity changed from None to Blocking

comment:5 Changed 15 years ago by Valik

  • Milestone set to 3.3.1.4
  • Resolution set to Fixed
  • Status changed from assigned to closed

Fixed in version: 3.3.1.4

comment:6 Changed 15 years ago by Valik

  • Milestone 3.3.1.4 deleted
  • Resolution Fixed deleted
  • Status changed from closed to reopened

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

comment:7 Changed 15 years ago by Valik

  • Severity changed from Blocking to None

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

comment:8 Changed 13 years ago by Valik

  • Milestone set to Future Release
  • Resolution set to Fixed
  • Status changed from reopened to closed

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

comment:9 Changed 13 years ago by Jpm

  • Milestone changed from Future Release to 3.3.7.20

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The owner will remain Valik.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.