CFLib.org – Common Function Library Project

BitFormat(num)

Last updated August 14, 2007

author

Trevor Orr

Version: 1 | Requires: CF5 | Library: StrLib

Description:
Format a value as 1 or 0.

Return Values:
Returns a number.

Example:

<cfoutput>
	1 = #BitFormat("1")#<br />
	0 = #BitFormat("0")#<br />
	x = #BitFormat("x")#<br />
	space = #BitFormat(" ")#<br />
	1+space = #BitFormat("1 ")#<br />
	2+space = #BitFormat("1 ")#<br />
</cfoutput>

Parameters:

Name Description Required
num Value to format. Yes

Full UDF Source:

/**
 * Format a value as 1 or 0.
 * 
 * @param num 	 Value to format. (Required)
 * @return Returns a number. 
 * @author Trevor Orr (fractorr@yahoo.com) 
 * @version 1, August 14, 2007 
 */
function BitFormat(num) {
	return (IIF(IsNumeric(Trim(arguments.num)) AND Trim(arguments.num) NEQ 0, 1, 0));
}
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