Skip to main content

View on GitHub

Open this notebook in GitHub to run it yourself

Bitwise Invert

The bitwise inversion operation receives a quantum register representing some number xx, and inverts its binary representation, namely, replaces 11s by 00s and vice versa.

Example

from classiq import *


@qfunc
def main(x: Output[QNum], y: Output[QNum]) -> None:
    x |= 6

    y |= ~x


qmod = create_model(main)

qprog = synthesize(qmod)

result = execute(qprog).result_value()
print(result.counts_of_multiple_outputs(["x", "y"]))
Output:
{('011', '100'): 1000}