BITTEST( ) Function Example

The following example uses BITTEST( ) to determine whether a series of integers are even. If an integer is even, the function IsEven returns true (.T.); otherwise, it returns false (.F.).

CLEAR
? '2 even? '
?? IsEven(2)  && Even, .T. returned
? '3 even? '
?? IsEven(3)  && Not even, .F. returned
? '0 even? '
?? IsEven(0)  && Even, .T. returned
? '-13 even? '
?? IsEven(-13)  && Not even, .F. returned

Function IsEven
   PARAMETER nInteger
   RETURN NOT BITTEST(nInteger, 0)