Skip to content

Commit

Permalink
Attempt to guarantee a uniform distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
moodmosaic committed Dec 19, 2017
1 parent 131dcc7 commit 0aff674
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions Src/Fare/Xeger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,9 @@ public string Generate()
/// <param name="random">The object used as the randomizer.</param>
/// <returns>A random number in the given range.</returns>
private static int GetRandomInt(int min, int max, Random random)
{
int dif = max - min;
double number = random.NextDouble();
return min + (int)Math.Round(number * dif);
{
int maxForRandom = max - min + 1;
return random.Next(maxForRandom) + min;
}

private void Generate(StringBuilder builder, State state)
Expand Down

0 comments on commit 0aff674

Please sign in to comment.