DecimalFormat(#number1#): #DecimalFormat(n
I think the problem is not DecimalFormat()
, but the typical floating-point rounding errors.
see: PrecisionEvaluate()
A quick fix would be to change line 1 to number1 = NumberFormat(20.5/80 * 100,'9.999')
DecimalFormat is a formatting function. Not a Mathematical function. Its job is not to round your number for you, unfortunately CF lacks good mathematical functions for decimals so you will have to write your own.
Here is one someone wrote on the CF livedocs page for round():
<cffunction name="roundDecimal" returntype="numeric">
<cfargument name="num" type="numeric" required="yes">
<cfargument name="decimal" type="numeric" default="2" required="no">
<cfreturn round(num*10^decimal)/10^decimal />
</cffunction>
Please see the CF documentation NumberFormat and do a page search on round to see some specific information.