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/Measurement.qs

22lines · modecode

1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT License.
3
4import Types.FixedPoint;
5import Convert.BoolArrayAsFixedPoint;
6import Std.Arrays.ForEach;
7import Std.Convert.ResultArrayAsBoolArray;
8
9
10/// # Summary
11/// Measure a fixed-point number, returns its value as Double, and resets
12/// all the register to zero.
13///
14/// # Input
15/// ## fp
16/// Fixed-point number to measure.
17@Config(FloatingPointComputations)
18operation MeasureFxP(fp : FixedPoint) : Double {
19 let measurements = MResetEachZ(fp::Register);
20 let bits = ResultArrayAsBoolArray(measurements);
21 return BoolArrayAsFixedPoint(fp::IntegerBits, bits);
22}
23