Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Ceiling(NaN()) causes an overflow #1107

Description

@weucode

Describe the bug
The result of Lg with a non-positive parameter is NaN, so running the following program will cause overflow. The part of the output is shown below:

Unhandled exception. System.OverflowException: Arithmetic operation resulted in an overflow.

To Reproduce

namespace NameSpace {
	open Microsoft.Quantum.Intrinsic;
	open Microsoft.Quantum.Math;


	@EntryPoint()
	operation main() : Unit {
		let nIdxRegQubits = Ceiling(Lg(-1.0));
		// same as:let nIdxRegQubits = Ceiling(NaN());
		Message($"{nIdxRegQubits}");
	}
}

Expected behavior
Maybe a range check can be used to avoid it.

System information
operating system : Ubuntu 22.04 LTS

dotnet version : 6.0.400

QDK : 0.25.228311

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions