• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Formating to Percent

LEGEND ,
Oct 06, 2007 Oct 06, 2007

Copy link to clipboard

Copied

I have a variable that is a long 0.1243453235 and I want to render it to a
percent. What function do I need to use?

And the darnest things is that I know this and cannot remember. :-)

--
Wally Kolcz
MyNextPet.org
Founder / Developer
586.871.4126


TOPICS
Advanced techniques

Views

283

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 06, 2007 Oct 06, 2007

Copy link to clipboard

Copied

I use this:

<cfset teampercent=(spadesalt.win/spadesalt.total_games)*100>

then output

#numberformat(teampercent,"999.99")# %

But this is of course contingent upon what you are basing your percentage on

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 06, 2007 Oct 06, 2007

Copy link to clipboard

Copied

That's close, but not exactly. I am getting:

Single Women 0.26%

How can I get it down to just 26%

The original number is: 0.26125513326308364


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 06, 2007 Oct 06, 2007

Copy link to clipboard

Copied

multiple results by 100 in a cfset statement

<cfset singlewomen=yourvar*100>

<cfoutput>#numberformat(singlewomen,"999")# %<cfoutput>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 06, 2007 Oct 06, 2007

Copy link to clipboard

Copied

LATEST
<p>
<cfset x=0.26125513326308364>
<cfset xAsPercent = 100 * x>
x = <cfoutput>#x#</cfoutput><br>
x as percent = <cfoutput>#round(xAsPercent)#%</cfoutput><br>
</p>

<p>
<cfset y=0.26525513326308364>
<cfset yAsPercent = 100 * y>
y = <cfoutput>#y#</cfoutput><br>
y as percent = <cfoutput>#round(yAsPercent)#%</cfoutput>
</p>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation