CFLib.org – Common Function Library Project

IsEven(num)

Last updated November 27, 2001

author

Mark Andrachek

Version: 1 | Requires: CF5 | Library: MathLib

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

Return Values:
Returna a Boolean.

Example:

<CFOUTPUT>
<CFLOOP FROM="1" TO="10" INDEX="i">
#i#: #IsEven(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 even, 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 IsEven(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 (not num mod 2);
  }
  else {
    return No;
  }
}
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