IsEven(num)
Last updated November 27, 2001
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;
}
}
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