In Coldfusion / CFML, how do you format a long decimal number to a standard two number percentage?
In Coldfusion / CFML I need to convert 0.85035035035 to 85%. I开发者_运维问答 looked at numberFormat(), but it's output looks like, "0.85". There doesn't seem to have a method to omit the leading "0.".
<cfset myNumber = 0.85035035035>
<cfoutput>
#numberFormat(myNumber, "0.00")#%
</cfoutput>
Outputs: 0.85%
Ideas? Do I need to trim the leading 2 characters in a second operation?
<cfset myNumber = 0.85035035035>
<cfset myPercent = numberFormat(myNumber, "0.00")>
<cfoutput>
#right(myPercent, 2)# %
</cfoutput>
<cfoutput>#Round(myNumber * 100)#%</cfoutput>
<cfset num = 0.85>
<cfoutput>#NumberFormat(num * 100,"999")#%</cfoutput>
精彩评论