How to Format Numbers as Percentages in ColdFusion


Like most dynamic programming languages, ColdFusion can perform mathematical operations with the variables that it handles. However, the results that it returns when it performs such calculations are not always visually appealing or easy to understand. Such is the case with long-form decimals. Displaying them as they are, even with a limit to the amount of numbers displayed, does not always accurately convey a meaning to your user. Fortunately, you can display long-form decimals as percentages in ColdFusion without making any changes to the value of the number.

  • Open the ColdFusion document with the variable you wish to display as a percentage.

  • Find or insert the variable that you wish to display. ColdFusion's variable format is the name of the variable between two pound signs, i.e. #DecimalNumber#.

  • Change the variable to the following format:

    NumberFormat(DecimalNumber*100, "__")#%

    The variable will be displayed as if it were multiplied by 100, with a percentage sign after it. The two underscores are the number mask that determine the format by which the number will display. You can place other characters within the mask, such as decimals, commas for thousand separators, and so on.

  • Save and publish your page. When your query is run, your long-form decimals will display as percentages.

Related Searches


  • Photo Credit Stockbyte/Stockbyte/Getty Images
Promoted By Zergnet


Related Searches

Check It Out

Geek Vs Geek: Robot battles, hoverboard drag race, and more

Is DIY in your DNA? Become part of our maker community.
Submit Your Work!