tracker issue : CF-3839552

select a category, or use search below
(searches all categories and all time range)
Title:

String compare not working correct on numeric values

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/Duplicate

Reporter/Name(from Bugbase): Dik Klop / Dik Klop (Dik Klop)

Created: 10/15/2014

Components: General Server

Versions: 11.0

Failure Type:

Found In Build/Fixed In Build: CF11_Final /

Priority/Frequency: Major / All users will encounter

Locale/System: English / Win 2008 Enterprise Svr 64-bit

Vote Count: 1

Duplicate ID:	CF-3134331

Problem Description:

When you try to compare two strings with a numeric value that also contains a comma, the result is true even the values are totally different

Steps to Reproduce:

<cfset number1 = "2,0" />
<cfset number2 = "0,000002" />
<cfdump var="#(number1 eq number2)#" />

Actual Result:

True

Expected Result:

False

Any Workarounds:

Removing ',0' from the first value solves the problem, but is not a workable workaround

<cfset number1 = "2" />
<cfset number2 = "0,000002" />
<cfdump var="#(number1 eq number2)#" />

this one gives the correct result.

Even casting the values to Java strings don't solve the problem.

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3839552

External Customer Info:
External Company:  
External Customer Name: Dik
External Customer Email:  
External Test Config: Tested on several configurations:



Windows 2008 R2, CF 11.0.0

Mac OS X 10.9, CF 11.0.2

Windows 7, CF 11.0.0

Windows 8, CF 11.0.0

Attachments:

Comments:

yes please, this is weird behaviour that affects our current application.
Vote by External U.
10622 | October 15, 2014 06:21:00 AM GMT
is it trying to be clever and comparing two lists with numeric values instead if we convert to numeric we get 2,0 and 0,2, if you were to treat these as two lists to compare and sorted them first you would get this behaviour. out of interest if you run the following code <cfset number1 = "2,01" /> <cfset number2 = "0,000002" /> <cfdump var="#(number1 eq number2)#" /> it is not equal, so there is some funky list / numeric conversion going on i think. This would be quite useful if you wanted to compare lists but its a bit crap if you are just trying to compare strings. PS - railo looks to get the STRING comparison of those two right on cflive
Comment by External U.
10620 | October 16, 2014 04:34:48 AM GMT
I suspect it is this: http://blog.adamcameron.me/2012/07/according-to-06-60-and-both-are.html So is already raised here: https://bugbase.adobe.com/index.cfm?event=bug&id=CF-3134331 The best "work around" is that if you're trying to compare strings: use the compare() function. That's what it's for.
Comment by External U.
10621 | October 22, 2014 04:20:33 PM GMT