CFLib.org – Common Function Library Project

IsOdd(num)

Last updated November 27, 2001

author

Mark Andrachek

Version: 1 | Requires: CF5 | Library: MathLib

Description:
This very simple but usefull UDF that returns true if the number passed is odd, or false if it is not.

Return Values:
Returna a Boolean.

Example:

<CFOUTPUT>
<CFLOOP FROM="1" TO="10" INDEX="i">
#i#: #IsOdd(i)#<BR>
</CFLOOP>
</CFOUTPUT>

Parameters:

Name Description Required
num Number you want to test. Yes

Full UDF Source:

/**
 * Returns true if the number passed it is odd, returns false if it is not.
 * 
 * @param num      Number you want to test. 
 * @return Returna a Boolean. 
 * @author Mark Andrachek (hallow@webmages.com) 
 * @version 1, November 27, 2001 
 */
function IsOdd(num) {
  // We only operate on numbers, otherwise we
  // we just return false.
  if (IsNumeric(num)) {
    //if it's evenly divisible by 2, it's
    //even. otherwise, it's odd. ;)
    return YesNoFormat(num MOD 2);
  }
  else {
    return No;
  }
}

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