Skip to main content

View on GitHub

Open this notebook in GitHub to run it yourself
The following comparators are supported:
  • Equal (denoted as ’==’)
  • NotEqual (denoted as ’!=’)
  • GreaterThan (denoted as ’>’)
  • GreaterEqual (denoted as ’>=’)
  • LessThan (denoted as ’<’)
  • LessEqual (denoted as ’<=’)
Note that integer and fixed-point numbers are represented in a 2-complement method during function evaluation. The binary number is extended in the case of a register size miss-match. For example, the positive signed number (110)2=6(110)_2=6 is expressed as (00110)2(00110)_2 when operating with a 5-qubit register. Similarly, the negative signed number (110)2=2(110)_2=-2 is expressed as (11110)2(11110)_2. Examples: (5 <= 3) = 0 (5 == 5) = 1 ((011)2(011)_2 == (11)2(11)_2) = 1 (signed (101)2(101)_2 < unsigned (101)2(101)_2) = 1

Examples

Example 1: Comparing Two Quantum Variables

This example generates a quantum program that performs ‘equal’ between two variables. The left arg is a signed variable with 5 qubits and the right arg is an unsigned varialbe with 3 qubits.

Example 2: Comparing Integer and Quantum Variable

This example generates a quantum program that performs ‘less equal’ between a quantum register and an integer. The left arg is an unsigned quantum variable with 3 qubits, and the right arg is an integer equal to
Output: