Is Number Even

From CodeCodex

PHP[edit]

<highlightsyntax> function IsEven($i){ return $i % 2 == 0; } </pre>

WinBatch[edit]

; WinBatch. Is number even resp. is number odd?

#DefineFunction udfIsOdd (intNumber)
Return intNumber & 1
#EndFunction

intNum1 = 11
blnIsOdd1 = udfIsOdd (intNum1)   ; @TRUE
blnIsEven1 = !udfIsOdd (intNum1) ; @FALSE

intNum2 = 12
blnIsOdd2 = udfIsOdd (intNum2)   ; @FALSE
blnIsEven2 = !udfIsOdd (intNum2) ; @TRUE

Exit
; This WinBatch code example was written by Detlev Dalitz.20090707.0050.CEST.