Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ranged Random.NextDouble #33

Closed
oliverbooth opened this issue Mar 7, 2021 · 1 comment
Closed

Ranged Random.NextDouble #33

oliverbooth opened this issue Mar 7, 2021 · 1 comment
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@oliverbooth
Copy link
Owner

oliverbooth commented Mar 7, 2021

Type

System.Random

Extension method signature

double NextDouble(double, double);

Parameters

Parameter Type Description
minValue double The inclusive lower bound of the random number returned.
maxValue double The inclusive upper bound of the random number returned.

Description
Returns a random double-precision floating point number that is within a specified range.

Benefits
System.Random does not support ranges for floating point values, Random.NextDouble() simply returns a value between 0-1. This extension method would offer this missing functionaality.

Drawbacks
n/a

(Optional) Implementation example

{
    return random.NextDouble() * (maxValue - minValue) + minValue;
}
@oliverbooth oliverbooth added the enhancement New feature or request label Mar 7, 2021
@oliverbooth oliverbooth added this to the 3.0.0 milestone Mar 7, 2021
@oliverbooth oliverbooth self-assigned this Mar 7, 2021
@oliverbooth
Copy link
Owner Author

Implemented in 9ebff19

oliverbooth added a commit that referenced this issue Mar 9, 2021
Behaves similar to Random.Next(int) where lower bound defaults to 0
oliverbooth added a commit that referenced this issue Mar 9, 2021
Behaves similar to Random.Next(int) where lower bound defaults to 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant