In ColdFusion, is there a numberFormat() mask to drop the decimal if it is 0?

eterps picture eterps · Jul 5, 2012 · Viewed 10.4k times · Source

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?

Answer

Henry picture Henry · Jul 5, 2012
<cfif int(x) eq x>
  #int(x)#
<cfelse>
  #DecimalFormat(x)#
</cfif>