Use this file to discover all available pages before exploring further.
View on GitHub
Open this notebook in GitHub to run it yourself
The Bitwise Or (denoted as ’|’) is implemented by applying the following 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 (110)2=6 is expressed as (00110)2 when operating with a five-qubit variable.
Similarly, the negative signed number (110)2=−2 is expressed as (11110)2.Examples:5 | 3 = 7 since 101 | 011 = 1115 | -3 = -3 since 0101 | 1101 = 1101-5 | -3 = -1 since 1011 | 1101 = 1111
This example generates a quantum program that performs bitwise ‘or’ between two variables.The left arg is a signed with five qubits and the right arg is unsigned with three qubits.
from classiq import *@qfuncdef main(a: Output[QNum], b: Output[QNum], res: Output[QNum]) -> None: allocate(5, True, 0, a) allocate(3, False, 0, b) a ^= 4 b ^= 5 res |= a | bqmod = create_model(main)
This example generates a quantum program that performs a bitwise ‘or’ 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.
@qfuncdef main(a: Output[QNum], res: Output[QNum]) -> None: a |= 4 res |= 3 | aqmod = create_model(main)