You are here: Function Reference > Alphabetical Listing > B > BitAnd

BitAnd

Use this function to return the result of a bitwise AND operation performed on two numeric values.

Syntax

BitAnd (Value1, Value2)

The parameters specify the numeric values on which the bitwise AND operation is performed. If either parameter is not an integer, it will be converted to an integer before the bitwise AND operation is performed.

The bitwise AND operation compares each bit of value1 to the corresponding bit of value2. If both bits are 1, the corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to zero (0). Note that integer values have 32 bits to compare.

The following table shows the result of a bitwise AND operation:

Value1 bit

Value2 bit

Result bit

0

0

0

0

   

1

   

1

 

0

Example

Here is an example:

x = 3 (3 is 0011 in binary)

y = 6 (6 is 0110 in binary)

 

z = BitAnd(x,y)

z = 2 (2 is 0010 in binary)

See also