I'd appreciate anyone's help here.
We have a financial app that does lots of calculation type things. To make
sure everything is good in the world, we utilize IsNumeric( ) a lot to validate
that things are number before processing.
Like so...
<cfif NOT IsNumeric(temp) >
Put up an error message
</cfif>
However, it appears that IsNumeric is not working with CF8. For example, it
does not recognize 7.865 or 6.500 as numbers... thus is failing our tests for
IsNumeric... when in fact they are numbers.
Anyone else experience this? Is there a quick workaround?
Azadi - 05 Sep 2007 08:16 GMT
in my tests both
<cfset temp = 7.650>
and
<cfset temp = "7.650">
validated correctly as numbers using
<cfif isnumeric(temp)>
not sure why on your system they do not....

Signature
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com
Adam Cameron - 05 Sep 2007 09:24 GMT
I did this:
<cfset temp = 7.650>
<cfoutput>#temp#: #isNumeric(temp)#</cfoutput><br />
<cfset temp = "7.650">
<cfoutput>#temp#: #isNumeric(temp)#</cfoutput><br />
<cfset temp = " 7.650">
<cfoutput>#temp#: #isNumeric(temp)#</cfoutput><br />
<cfset temp = "7.650 ">
<cfoutput>#temp#: #isNumeric(temp)#</cfoutput><br />
And the third one failed. So check for leading spaces in your data.
I think the fourth one should have failed too, really. I'm not sure why CF
takes it upon itself to ignore my trailing spaces.

Signature
Adam
Azadi - 05 Sep 2007 10:31 GMT
you know, 7.650E-12 is also a number, which it is in scientific
notation, so CF/underlying Java must be doing some format conversions to
determine if passes string is a number or not, 'cos just 7.650E
fails.... but then what sort of conversion will accept and pass/convert
trailing space but not leading space?... smells like something fishy to
me....
<cfset temp = "7.650E-12">
<cfoutput>#temp#: #isNumeric(temp)#</cfoutput><br /><!--- YES --->
<cfset temp = "7.650E">
<cfoutput>#temp#: #isNumeric(temp)#</cfoutput><br /><!--- NO --->

Signature
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com
Louis Galipeau - 05 Sep 2007 14:09 GMT
> I did this:
>
[quoted text clipped - 17 lines]
> --
> Adam
I was able to reproduce this as well on our coldfusion servers: CF7
all of them passed, and on CF8 the third one failed.
GArlington - 05 Sep 2007 09:45 GMT
> I'd appreciate anyone's help here.
>
[quoted text clipped - 13 lines]
>
> Anyone else experience this? Is there a quick workaround?
What's the regional/language settings on your server? Some countries
use ',' as decimal separator...
tclaremont - 05 Sep 2007 19:55 GMT
Use the trim() function on your numbers to reduce the hassle of leading and trailing spaces.
tomj - 06 Sep 2007 20:27 GMT
This was broken in CF8 and will be fixed in a future release.
In the mean time, a Trim() on the data is the best workaround.
Sorry about that.