BITTEST( ) Function
Returns True (.T.) if a specified bit in a numeric value is set to 1; otherwise, returns False (.F.).
BITTEST(nExpression1, nExpression2)
Return Values
Logical
Parameters
- nExpression1
Specifies the numeric value in which a bit is checked. If nExpression1 is not an integer, it is converted to an integer before its bit is checked. - nExpression2
Specifies the bit position in nExpression1 that is checked. nExpression2 can range from 0 to 31; 0 is the rightmost bit.
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)
See Also
BITAND( ) | BITCLEAR( ) | BITLSHIFT( ) | BITNOT( ) | BITOR( ) | BITRSHIFT( ) | BITSET( ) | BITXOR( )