View on GitHub
Open this notebook in GitHub to run it yourself
Bitwise Xor
The Bitwise Xor (denoted as ’^’) is implemented by applying this truth table between each pair of qubits (or qubit and bit) in variables A and B. Note that integer and fixed-point numbers are represented in a two-complement method during function evaluation. The binary number is extended in the case of a variable size mismatch. For example, the positive signed number is expressed as when operating with a five-qubit variable. Similarly, the negative signed number is expressed as . Examples: 5 ^ 3 = 6 since 101 ^ 011 = 110 5 ^ -3 = -8 since 0101 ^ 1101 = 1000 -5 ^ -3 = 6 since 1011 ^ 1101 = 0110Examples
Example 1: Two Quantum Variables
This example generates a quantum program that performs bitwise ‘xor’ between two variables. The left arg is a signed with five qubits and the right arg is unsigned with three qubits.Output:
Example 2: Integer and Quantum Variable
This example generates a quantum program that performs a bitwise ‘xor’ between a quantum variable and an integer. The left arg is an integer equal to three and the right arg is an unsigned quantum variable with three qubits.Output: