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.

DrawRandomInt should work when min and max are equal #602

@rhpreston

Description

@rhpreston

Describe the bug

DrawRandomInt produces an ExecutionFailExecption when min and max parameters are equal.

To Reproduce

Call Microsoft.Quantum.Random.DrawRandomInt with the same number for min and max. For example, DrawRandomInt(0, 0).

Expected behavior

Random integer functions typically allow a range of 1, for situations where the range may be variable. For example, I would expect to be able to select a random index of an array like this:

// assume "array" is of length > 0
let randomIndex = DrawRandomInt(0, Length(array) - 1);

Actual behavior

The above code will fail if array is of length 1.

System information

N/A

Additional context
To be clear, the current behavior is intended per the documentation. Really the purpose of this issue is to ask if there is a reason why DrawRandomInt was implemented this way, and if the team would consider changing it.

Thanks 😄

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions