ModPowL may entry a loops when set exponent to "0L"
Description
When set exponent and modulus to 0L, in the source code, the function ModPowL should not enter the loop and return 1L. However, in the following test case, there is a Unhandled exception which indicates there is a divide by zero operation.
source code
https://github.com/microsoft/qsharp-runtime/blob/f56539bd799c5f47e01a9baf648b63a063b21a88/src/Simulation/QSharpFoundation/Math/Math.qs#L327
Testcase
namespace NISLNameSpace {
open Microsoft.Quantum.Math;
open Microsoft.Quantum.Intrinsic;
@EntryPoint()
operation main() : Unit {
let value = 1L;
let exponent = 0L;
let modulus = 0L;
let NISLModPowL = ModPowL(value,exponent,modulus);
Message($"{value}");
Message($"{exponent}");
Message($"{modulus}");
Message($"{NISLModPowL}");
}
}
Environment
operating system : Windows 10 and Ubuntu 18.06 dotnet version : 6.0.400 QDK : 0.25.228311
The real running code is here. https://github.com/microsoft/qsharp-runtime/blob/1ac2e3cd154145536fab030b728b4439526d2bb3/src/Simulation/QSharpFoundation/Math/Math.cs#L105 It raises an exception correctly because this program tries to make the divisor 0. Moreover, I'd like to know when this code will execute, because this may decide whether it is necessary to add more operation for the situation that modulus=0.