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));
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson