GreaterThan operation

Warning

This documentation refers to the Classic QDK, which has been replaced by the Modern QDK.

Please see https://aka.ms/qdk.api for the API documentation for the Modern QDK.

Namespace: Microsoft.Quantum.Arithmetic

Package: Microsoft.Quantum.Standard

Applies a greater-than comparison between two integers encoded into qubit registers, flipping a target qubit based on the result of the comparison.

operation GreaterThan (xs : Microsoft.Quantum.Arithmetic.LittleEndian, ys : Microsoft.Quantum.Arithmetic.LittleEndian, result : Qubit) : Unit is Adj + Ctl

Description

Carries out a strictly greater than comparison of two integers $x$ and $y$, encoded in qubit registers xs and ys. If $x > y$, then the result qubit will be flipped, otherwise the result qubit will retain its state.

Input

xs : LittleEndian

LittleEndian qubit register encoding the first integer $x$.

ys : LittleEndian

LittleEndian qubit register encoding the second integer $y$.

result : Qubit

Single qubit that will be flipped if $x > y$.

Output : Unit

Remarks

Uses the trick that $x - y = (x'+y)'$, where ' denotes the one's complement.

References