> -----Original Message-----
> From: Evan Lavidor [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, June 19, 2001 3:59 PM
> To: CF-Talk
> Subject: IsNumeric weirdness - can someone explain this?
>
>
> Here's the test code:
>
> ---------------------------------------------
> <cfset myvariable = "3D1">
> <cfoutput>
> <p>#IsNumeric('3D1')#</p>
> <p>#myvariable#</p>
> <p>#IsNumeric(myvariable)#</p>
> </cfoutput>
>
> This returns:
> Yes
> 3D1
> Yes
>
> ---------------------------------------------
>
> WTF?!? Shouldn't I be seeing No, 3D1, No? Is it evaluating "3D1" as a
> binary or hex value of some kind? Why is it passing an IsNumeric
> test? I'm
> running 4.5.1SP2.
>
> Interestingly, 3A1, 3B1, 3C1, and 3F1 all fail, but 3E1 produces the same
> result.
>
Evan,
Thanks for wasting my time! ;) Well I had to figure out why the heck this was
happening, and I found out it's because it's assuming the value is written in
scientific notation. I haven't been able to find out WHY "d" works just like "e"
(exponential notation as in 24e-2 = 0.24), but it seems to do the same thing:
<cfset myvariable = "24e-2">
<cfoutput>
<p>#IsNumeric("24e-2")#</p>
<p>#myvariable#</p>
<p>#IsNumeric(myvariable)#</p>
<p>#Val(myvariable)#</p>
</cfoutput>
returns:
YES
24e-2
YES
0.24
----------------------------------------
<cfset myvariable = "24d-2">
<cfoutput>
<p>#IsNumeric("24d-2")#</p>
<p>#myvariable#</p>
<p>#IsNumeric(myvariable)#</p>
<p>#Val(myvariable)#</p>
</cfoutput>
returns:
YES
24d-2
YES
0.24
Notice I added the Val() function in there, which made me arrive at the conclusion
that CF is treating the D the same as E and is using it as an exponent.
Have fun!
-Andy
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists