2009-06-26

Number is Even or Page is Even / Odd

/*

Determine if a passed value is even or odd

*/
//
function isEven(value){
//-------------------------------------------------------------------------
//-- I S E V E N
//-------------------------------------------------------------------------
//-- Generic: Yes. Generic JavaScript, works with all versions and is
//-- self contained -- calls nothing.
//-------------------------------------------------------------------------
//-- Purpose: Determeins if a value is even or odd. Was originally used
//-- to see if the number of a page was even (a left hand page) or
//-- odd (a right hand page).
//-------------------------------------------------------------------------
//-- Returns: true if the passed value is considered to be an even
//-- number or false otherwise. Works with all types of values.
//-------------------------------------------------------------------------
//-- Function from: http://archives.hwg.org/hwg-techniques/38CCFF2B.B763AE47@mitre.org
//-- found 2008.08.08. Source not determinable. No copyright listed.
//-------------------------------------------------------------------------
//-- Modified by: electronic publishing support
//-------------------------------------------------------------------------
//-- % is the Modulus function.
//-- %2 == 0 means divide by 2 and see if the remainder is 0
try {
return ( value%2 == 0 ) ;
}
catch (anError) {
return false ;
}
}

No comments:

Post a Comment