JavaScript Editor js editor     Web development 



Main Page

Determines whether a specific bit in a Numeric, Varbinary, or Blob value is set to 1. There is a numeric and a binary version of the syntax.

Note:
If the specified expression is not an integer, it is converted to an integer before performing the operation.

BITTEST(nNumericExpression1, nNumericExpression2)
BITTEST(BinaryExpression, nBitNumber)

Parameters

nNumericExpression1


Specifies the Numeric value to check for the specified bit.
nNumericExpression2


Specifies the bit position in nExpression1 to check. nExpression2 can range from 0 to 31 with 0 as the bit farthest to the right.
BinaryExpression


Specifies a Varbinary or Blob expression to check for the specified bit.
nBitNumber


Specifies a zero-based bit in qExpression. If nBitNumber is out of range of qExpression, Visual FoxPro generates an error.

Return Value

Logical. BITTEST(В ) returns True (.T.) if the specified bit is set to 1; otherwise, it returns False (.F.).

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.).

В Copy Code
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



JavaScript Editor js editor     Web development