﻿BitAnd Function (Binary, Binary[])

Performs a bitwise AND operation on two or more values of Numeric, Varbinary, or Blob type and returns the result. There is a numeric and a binary version of the syntax.

Namespace:  XSharp.VFP
Assembly:  XSharp.VFP (in XSharp.VFP.dll) Version: 2.19
Syntax
``` FUNCTION BitAnd(
Arg1 AS BINARY,
Arg2 PARAMS BINARY[]
) AS BINARY```

#### Parameters

Arg1
Type: Binary
Specifies Varbinary or Blob values to perform the bitwise AND operation.
Arg2
Type: Binary
Specifies Varbinary or Blob values to perform the bitwise AND operation.

#### Return Value

Type: Binary
Numeric or Varbinary. BitAnd( ) returns the result of the bitwise AND operation performed on the specified expressions. For Varbinary or Blob values, the return value is calculated as if all values are padded with 0h00 on the right of the value up to the length of the longest value. The appropriate operation is then performed between those values.
Remarks
Note
You can specify a maximum of 26 values. The specified values must have the same type. If the specified expressions are not integers, they are converted to integers before performing the operation.

BitAnd( ) compares each bit in eExpressionN to the corresponding bit in eExpressionN+1. If the bits in eExpressionN and eExpressionN+1 are both 1, the corresponding result bit is set to 1; otherwise, the corresponding result bit is set to 0.
The following table shows the result of a bitwise AND operation on corresponding eExpressionN and eExpressionN+1 bits:
eExpressionN biteExpressionN+1 bitResulting bit
000
010
111
100
Examples
X#
```1x = 3  // 0011 binary
2y = 6  // 0110 binary
3? BitAnd(x,y) // Returns 2, 0010 binary```