CFLib.org – Common Function Library Project

verityPercentage(num)

Last updated May 9, 2003

author

Howard Owens

Version: 1 | Requires: CF5 | Library: StrLib

Description:
Takes a verity "score" value and returns a formatted percentage. When verity returns a score, it usually looks like 0.87454, which is not an intuitive number for site browser to discern. This UDF formats the SCORE into something 88%, which is easier to read.

Return Values:
Returns a string.

Example:

<cfset score="0.87899">

<CFOUTPUT>
#verityPercentage(score)#
</CFOUTPUT>

Parameters:

Name Description Required
num Verity score. Yes

Full UDF Source:

/**
 * Takes a verity &quot;score&quot; value and returns a formatted percentage.
 * 
 * @param num 	 Verity score. (Required)
 * @return Returns a string. 
 * @author Howard Owens (howens@insidevc.com) 
 * @version 1, August 10, 2003 
 */
function verityPercentage(num){
	var outNum = '';
	var leftDigit=ListFirst(num, '.');
	var rightDigits=Left(ListGetAt(num, 2, '.'), 2);
	
	if (right(rightDigits, 2) GTE 5) rightDigits = rightDigits+1;

	if (leftDigit gte 1) outNum='100' & '%';
	else outNum=RightDigits & '%';
	
	return outNum;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson