troubleshooting Question

*** NOT A NEWBIE *** - Is there a bug in CFLOOP with decimal STEP?

Avatar of drgdrg
drgdrg asked on
Web Servers
5 Comments1 Solution277 ViewsLast Modified:
OK - we were working on a complex app when we ran across a glitch.  We finally stripped out all of the interesting code, leaving ourselves with just the loop, and I can't believe what I'm seeing.  Can anyone comment on this ---

<CFLOOP from="1.3" to="0.7" step="-0.1" index="x">
      <CFOUTPUT><strong>x=#x# ... int(x*100)/100=#evaluate(int(x*100)/100)#</strong> ... </CFOUTPUT>
      <CFIF x GT 1>x gt 1 ...</cfif>
      <CFIF int(x*100)/100 EQ 1>x eq 1 ...</cfif>
      <CFIF x LT 1>x lt 1 ...</cfif>
      <BR>
</CFLOOP>

What this SHOULD run as is:

x=1.3 ... int(x*100)/100=1.3 ... x gt 1 ...
x=1.2 ... int(x*100)/100=1.2 ... x gt 1 ...
x=1.1 ... int(x*100)/100=1.09 ... x gt 1 ...
x=1 ... int(x*100)/100=1 ... x eq 1 ...
x=0.9 ... int(x*100)/100=0.9 ... x lt 1 ...
x=0.8 ... int(x*100)/100=0.8 ... x lt 1 ...
x=0.7 ... int(x*100)/100=0.7 ... x lt 1 ...

But what we are seeing is:

x=1.3 ... int(x*100)/100=1.3 ... x gt 1 ...
x=1.2 ... int(x*100)/100=1.2 ... x gt 1 ...
x=1.1 ... int(x*100)/100=1.09 ... x gt 1 ...   <<<<<< Look Here
x=1 ... int(x*100)/100=0.99 ... x lt 1 ...    <<<<<< Look Here
x=0.9 ... int(x*100)/100=0.89 ... x lt 1 ...    <<<<<< Look Here
x=0.8 ... int(x*100)/100=0.8 ... x lt 1 ...
x=0.7 ... int(x*100)/100=0.7 ... x lt 1 ...

When I change the script to:

<CFLOOP from="1.3" to="0.7" step="-0.1" index="x">
      <CFOUTPUT><strong>x=#x# ... int(x*100000)/100000=#evaluate(int(x*100000)/100000)#</strong> ... </CFOUTPUT>
      <CFIF x GT 1>x gt 1 ...</cfif>
      <CFIF int(x*100)/100 EQ 1>x eq 1 ...</cfif>
      <CFIF x LT 1>x lt 1 ...</cfif>
      <BR>
</CFLOOP>

I get ...

x=1.3 ... int(x*100000)/100000=1.3 ... x gt 1 ...
x=1.2 ... int(x*100000)/100000=1.2 ... x gt 1 ...
x=1.1 ... int(x*100000)/100000=1.09999 ... x gt 1 ...
x=1 ... int(x*100000)/100000=0.99999 ... x lt 1 ...
x=0.9 ... int(x*100000)/100000=0.89999 ... x lt 1 ...
x=0.8 ... int(x*100000)/100000=0.8 ... x lt 1 ...
x=0.7 ... int(x*100000)/100000=0.7 ... x lt 1 ...

Could it be some sort of floating point glitch in CF (or Java) when stepping backwards?  I'm totally at a loss - really.
Can anyone recreate this problem?  Any ideas on what would cause it?

I'm on MX 7 Standard ... Version: 7,0,1,116466  
Windows 2000 Server
Dell with Dual Xeons
Update Level /C:/CFusionMX7/lib/updates/chf7010001.jar  
Java version 1.4.2_08

FYI, when I run the test "forwards", ie:
<CFLOOP from="0.7" to="1.3" step="0.1" index="x">
      <CFOUTPUT><strong>x=#x# ... int(x*100000)/100000=#evaluate(int(x*100000)/100000)#</strong> ... </CFOUTPUT>
      <CFIF x GT 1>x gt 1 ...</cfif>
      <CFIF int(x*100)/100 EQ 1>x eq 1 ...</cfif>
      <CFIF x LT 1>x lt 1 ...</cfif>
      <BR>
</CFLOOP>

I get the same crazy results:
x=0.7 ... int(x*100000)/100000=0.7 ... x lt 1 ...
x=0.8 ... int(x*100000)/100000=0.8 ... x lt 1 ...
x=0.9 ... int(x*100000)/100000=0.89999 ... x lt 1 ...
x=1 ... int(x*100000)/100000=0.99999 ... x lt 1 ...
x=1.1 ... int(x*100000)/100000=1.09999 ... x gt 1 ...
x=1.2 ... int(x*100000)/100000=1.2 ... x gt 1 ...
x=1.3 ... int(x*100000)/100000=1.3 ... x gt 1 ...

At least now I know I'm not crazy (could not figure out why 1 would not equal 1 until we built the above test).

HELP !!!! : )

Thanks
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros