BitTest

Use this function to return TRUE (1) if the specified bit in a value is a 1; otherwise return FALSE (0).

Syntax

BitTest(Value1, BitPos)

Parameters specify the numeric value and the bit position on which the operation is performed. The specified bit is tested for a 1 value. If the bit is a 1, then 1 is returned. If the bit is zero (0), then zero (0) is returned. Specifying a negative or zero bit position will result in zero (0) being returned.

Note that integer values have 32 bits. When looking at the value in binary form, bit 1 is on the left and bit 32 is on the right.

Bit 32 -->0000 0000 0000 0000 0000 0000 0000 0000<-- Bit 1

Example

Here is an example:

y = 6 (6 is 0110 in binary)

z = BitTest(x,1)

z = 0 (bit 1 was not on)

 

y = 6 (6 is 0110 in binary)

z = BitTest(x,2)

z = 1 (bit 2 was on)

See also