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
Steven A. Cuccaro, Thomas G. Draper, Samuel A. Kutin, David Petrie Moulton: "A new quantum ripple-carry addition circuit", 2004. https://arxiv.org/abs/quant-ph/0410184v1
Thomas Haener, Martin Roetteler, Krysta M. Svore: "Factoring using 2n+2 qubits with Toffoli based modular multiplication", 2016 https://arxiv.org/abs/1611.07995
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for