BitXor

This reference topic applies to FQL v4. Go to this page for the latest FQL v10 reference topics.

BitXor( value_1, [ value_2, ... ] )
BitXor( value_1, [ value_2, ... ] )
BitXor( value_1, [ value_2, ... ] )
bitxor( value_1, [ value_2, ... ] )
BitXor( value_1, [ value_2, ... ] )

Description

The BitXor function returns the bit in the result if the bit exists in only one argument. The arguments must be numbers, and the fractional portion is truncated before the XOR operation is applied. The result is the bitwise exclusive OR of all of the arguments.

Parameters

Parameter Type Definition and Requirements

value

List of Numbers

One or more numbers to bitwise exclusive OR.

Returns

A Number which is the bitwise exclusive OR of all supplied values.

Examples

The following query executes an array of independent bitwise exclusive OR operations and returns results in the result array. The result array position matches the position in the execution array.

try
{
    Value result = await client.Query(
        Arr(
            BitXor(7),
            BitXor(0, 0),
            BitXor(1, 0),
            BitXor(1, 1),
            BitXor(6, 3)
        )
    );

    Console.WriteLine(result);
}
catch (Exception e)
{
    Console.WriteLine($"ERROR: {e.Message}");
}
Arr(LongV(7), LongV(0), LongV(1), LongV(0), LongV(5))
result, err := client.Query(
	f.Arr{
		f.BitXor(7),
		f.BitXor(0, 0),
		f.BitXor(1, 0),
		f.BitXor(1, 1),
		f.BitXor(6, 3),
	})

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
[7 0 1 0 5]
client.query(
  [
    q.BitXor(7),
    q.BitXor(0, 0),
    q.BitXor(1, 0),
    q.BitXor(1, 1),
    q.BitXor(6, 3),
  ]
)
.then((ret) => console.log(ret))
.catch((err) => console.error(
  'Error: [%s] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
[ 7, 0, 1, 0, 5 ]
result = client.query(
  [
    q.bitxor(7),
    q.bitxor(0, 0),
    q.bitxor(1, 0),
    q.bitxor(1, 1),
    q.bitxor(6, 3),
  ]
)
print(result)
[7, 0, 1, 0, 5]
[
  BitXor(7),
  BitXor(0, 0),
  BitXor(1, 0),
  BitXor(1, 1),
  BitXor(6, 3),
]
[ 7, 0, 1, 0, 5 ]
Query metrics:
  •    bytesIn:  82

  •   bytesOut:  24

  • computeOps:   1

  •    readOps:   0

  •   writeOps:   0

  •  readBytes:   0

  • writeBytes:   0

  •  queryTime: 2ms

  •    retries:   0

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!