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

@weucode

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

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