BitAnd

BitAnd( value_1, [ value_2, ... ] )
BitAnd( value_1, [ value_2, ... ] )
BitAnd( value_1, [ value_2, ... ] )
BitAnd( value_1, [ value_2, ... ] )
bitand( value_1, [ value_2, ... ] )
BitAnd( value_1, [ value_2, ... ] )

Description

The BitAnd function returns the bit to the result if the bit exists in all numbers. The arguments must be numbers, and fractional values are truncated before the operation is applied. The result is the bitwise AND of all the arguments.

Parameters

Argument Type Definition and Requirements

value

List of Numbers

One or more numbers to bitwise AND.

Returns

A number which is the bitwise AND of all supplied values.

Examples

The following query executes an array of independent bitwise AND operations and returns the answer in the result array. The result array position matches the position in the execution array.

Value result = await client.Query(
    Arr(
        BitAnd(7),
        BitAnd(0, 0),
        BitAnd(1, 0),
        BitAnd(1, 1),
        BitAnd(7, 3)
    )
);

Console.WriteLine(result);
Arr(LongV(7), LongV(0), LongV(0), LongV(1), LongV(3))
result, err := client.Query(
	f.Arr{
		f.BitAnd(7),
		f.BitAnd(0, 0),
		f.BitAnd(1, 0),
		f.BitAnd(1, 1),
		f.BitAnd(7, 3),
	})

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
[7 0 0 1 3]
System.out.println(
    client.query(
        Arr(
            BitAnd(Value(7)),
            BitAnd(Value(0),Value(0)),
            BitAnd(Value(1),Value(0)),
            BitAnd(Value(1),Value(1)),
            BitAnd(Value(7),Value(3))
        )
    ).get());
[7, 0, 0, 1, 3]
client.query(
  [
    q.BitAnd(7),
    q.BitAnd(0, 0),
    q.BitAnd(1, 0),
    q.BitAnd(1, 1),
    q.BitAnd(7, 3),
  ]
)
.then((ret) => console.log(ret))
.catch((err) => console.error('Error: %s', err))
[ 7, 0, 0, 1, 3 ]
result = client.query(
  [
    q.bitand(7),
    q.bitand(0, 0),
    q.bitand(1, 0),
    q.bitand(1, 1),
    q.bitand(7, 3)
  ]
)
print(result)
[7, 0, 0, 1, 3]
println(Await.result(
    client.query(
        Arr(
            BitAnd(7),
            BitAnd(0, 0),
            BitAnd(1, 0),
            BitAnd(1, 1),
            BitAnd(7, 3)
        )
    ),
    5.seconds
))
[7, 0, 0, 1, 3]

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve!
Visit Fauna's Discourse forums or email docs@fauna.com

Thank you for your feedback!