microsoft / QuantumLibraries

Q# libraries for the Quantum Development Kit

Home Page:https://docs.microsoft.com/quantum

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MeasureFxP fails to return smallest representable number

msoeken opened this issue · comments

Describe the bug
When measuring a quantum register in a state that corresponds to the smallest representable fixed-point number, MeasureFxP returns -0.0 instead of the correct value.

To Reproduce

Failing test case:

@Test("ToffoliSimulator")
operation FailingTest() : Unit {
    use qs = Qubit[4];
    let fxp = FixedPoint(2, qs);

    // bit pattern 00.00
    ApplyPauliFromBitString(PauliX, true, [false, false, false, false], qs);
    NearEqualityFactD(MeasureFxP(fxp), 0.0);

    // bit pattern 10.00
    ApplyPauliFromBitString(PauliX, true, [false, false, false, true], qs);
    NearEqualityFactD(MeasureFxP(fxp), -2.0);
}

Expected behavior
Test case should pass.