开发者

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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜