> -----Original Message-----
> From: Barney Boisvert [mailto:[EMAIL PROTECTED]
> Sent: Friday, September 30, 2005 2:03 PM
> To: CF-Talk
> Subject: Re: type=numeric bug
> 
> Whoops.  I meant trailing space, not trailing slash.  Sorry about
> that.  Basically CF says "34 " is a valid numeric value, in all MX
> versions.  Here's a better test to illustrate:
> 
> Surely this is a bug?

I dunno... I can see two sides of this:

1) It is a bug.  It's clear that "34 " is not a number.  Spaces aren't
numbers!  Simple.

2) It's not a bug.  CF does its level best to do type conversions.  "34 " is
easily considered a number (via trimming) and, more importantly, can be used
as a number by all (most?) CF operations.  For example the following code
returns "37".

<cfset foo = "34 " />
<cfset faa = foo + 3 />
<cfoutput>#faa#</cfoutput>

The really question, I think, is whether "IsNumber()" checks to see if
something is a number or if it checks to see if something can be used as a
number by CF.  It's a subtle difference but explains the behavior.

I've often thought that most of the "is" functions should take a second
(optional) parameter called "strict".  This would enable or disable a
stricter parser.  For example "isBoolean(Foo, true)" would only return true
if the value was "true" or "false".  "isDate(Foo, true)" would only return
true if the value was a CF data value (not a string which looks like a
date).

So, in this imaginary world:

<cfset foo = "34 " />
<cfoutput>#isNumeric(foo)#, #isNumeric(foo, false)#, #isNumeric(foo,
true)#</cfoutput>

Would return "true, true, false".

Jim Davis



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:219784
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to