In ColdFusion, is there a numberFormat() mask to drop the decimal if it is 0?
I do not think there is an existing function, but this rounding example might do the trick:
round(yourNumber * 100) / 100
EDIT:
As JasonM mentioned in the comments this will not produce two decimal places for numbers like 1.1
.
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.
Ok, I know this question is years old and my solution is dumb as hell but it worked for my needs:
#replace(dollarformat(list_price), '.00', '')#
I know this was dollarformat not number format, but the concept is the same.
LOL. If it's dumb and it works it's not dumb, right?
<cfif int(x) eq x>
#int(x)#
<cfelse>
#DecimalFormat(x)#
</cfif>