I'm trying to format numbers so that 2 decimal places show up, unless it is a whole number - then I don't want a decimal point to show. I've tried 0.00
, _.__
, 9.99
and several combinations. Is there a mask for the numberFormat
function that can get this result?
<cfif int(x) eq x>
#int(x)#
<cfelse>
#DecimalFormat(x)#
</cfif>
You could divide the variable by 1 and then the whole number is shown without a decimal place.
<cfset a = 5.00>
<cfset b = 5.55>
<cfoutput>#a/1#, #b/1#</cfoutput>
Output is 5, 5.55
. Instead of 5.00, 5.55
if you don't divide by 1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With