microsoft/qdk

Public

mirrored fromhttps://github.com/microsoft/qdkAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
8a151f109cece83aeea78e74d62cd6f25e7996a3

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

library/fixed_point/src/Comparison.qs

29lines · modecode

1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT License.
3
4import Types.FixedPoint;
5import Facts.AssertFormatsAreIdenticalFxP;
6import Signed.Comparison.CompareGTSI;
7
8/// # Summary
9/// Compares two fixed-point numbers stored in quantum registers, and
10/// controls a flip on the result.
11///
12/// # Input
13/// ## fp1
14/// First fixed-point number to be compared.
15/// ## fp2
16/// Second fixed-point number to be compared.
17/// ## result
18/// Result of the comparison. Will be flipped if `fp1 > fp2`.
19///
20/// # Remarks
21/// The current implementation requires the two fixed-point numbers
22/// to have the same point position and the same number of qubits.
23operation CompareGreaterThanFxP(fp1 : FixedPoint, fp2 : FixedPoint, result : Qubit) : Unit is Adj + Ctl {
24 AssertFormatsAreIdenticalFxP([fp1, fp2]);
25
26 CompareGTSI((fp1::Register), (fp2::Register), result);
27}
28
29export CompareGreaterThanFxP;