|
|
On Apr 8, 4:22 pm, "jdparlin" <webforumsu...@xxxxxxxxxxxxxx> wrote:
> I'm guessing you replied at the same time I was clarifying my need but as you
> can see I am using percentages and I need both 3.2 and 3.7 to be 3
>
> Thanks
Ok, so there are essentially two things going on here..
1) you want to divide 58 by 100 and get a precise answer
2) you want to round all your results down, and fix will do this if 1)
is ok
so the answer to 1) is, you'll need to use java to do you calculations
directly, bypassing cf's flawed maths.
<cfset numShows = createObject("java",
"java.math.BigDecimal").init(javaCast("string", "58"))>
<cfset numApps = createObject("java",
"java.math.BigDecimal").init(javaCast("string", "100"))>
<cfset num100 = createObject("java",
"java.math.BigDecimal").init(javaCast("string", "100"))>
<cfset result = numShows.divide(numApps, javacast("int", 9), 1)>
<cfset percent = result.multiply(num100)>
<cfoutput>
result = #numberformat(result, "9.999999999999")# <br>
percent = #numberformat(percent, "9.999999999999")# <br>
fix = #fix(percent)# %
</cfoutput>
Chris
|
|