• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CF8 IsNumeric not working??

Explorer ,
Sep 04, 2007 Sep 04, 2007

Copy link to clipboard

Copied

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?
TOPICS
Advanced techniques

Views

1.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Employee , Sep 06, 2007 Sep 06, 2007
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.

Votes

Translate

Translate
LEGEND ,
Sep 05, 2007 Sep 05, 2007

Copy link to clipboard

Copied

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....

--

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 05, 2007 Sep 05, 2007

Copy link to clipboard

Copied

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.

--
Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 05, 2007 Sep 05, 2007

Copy link to clipboard

Copied

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 --->
--

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 05, 2007 Sep 05, 2007

Copy link to clipboard

Copied

Use the trim() function on your numbers to reduce the hassle of leading and trailing spaces.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Sep 06, 2007 Sep 06, 2007

Copy link to clipboard

Copied

LATEST
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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation