ColdFusion Can't Subtract Decimals
Posted on 2006-06-15
OK, This is a nutty one.
Run this code and tell me what result you get.
<cfset number_one = 179.03>
<cfset number_two = 179.02>
<cfset the_difference = number_one - number_two>
I should mention I am running CFMX 7.01 on Win2K3
The result I get is 0.00999999999999 and I have checked it repeatedly and run JUST that function on the page with no other code at all... same result.
Now I know I can round but the mere fact that ColdFusion can't subtract decimal figures is particularly frightening. Its is simply not feasible to place the round() function on every use of a fraction in an application.
Anyone have any ideas what is causing this?
** More info - only seems to happen when result is the result is (should be) 0.01 as I tested lots of other options which worked fine. This is more bizarre by the minute.