CFLib.org – Common Function Library Project

BitFormat(num)

Last updated August 14, 2007
Download UDF

author

Trevor Orr                                        Trevor Orr

Version: 1 | Requires: ColdFusion 5 | Library: StrLib

 
Rated 0 time(s). Average Rating: 0

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:

<cfscript>
/**
* 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));
}
</cfscript>

Search CFLib.org


Latest Additions

Ryan Thompson-Jewell Ryan Thompson-Jewell added
ListSplit
1 day(s) ago

Nathan Dintenfass Nathan Dintenfass added
RowsToColumns
1 day(s) ago

Barney Boisvert Barney Boisvert added
indentXml
2 day(s) ago

Barney Boisvert Barney Boisvert added
REReplaceCallbac...
2 day(s) ago

Top Rated

Rob Brooks-Bilson                                 FolderSize
Rated 5.0, 7 time(s)

Nick Giovanni                                     UniqueValueList
Rated 5.0, 5 time(s)

James Sleeman                                     QuickSort
Rated 5.0, 3 time(s)

Jeff Howden ListDeleteDuplic...
Rated 5.0, 3 time(s)

Created by Raymond Camden / Design by Justin Johnson