Skip to content
Snippets Groups Projects
Commit 5fb65e27 authored by Seilenthal's avatar Seilenthal
Browse files

Random Generator V1.2)

parent 0f64a7b2
No related branches found
No related tags found
No related merge requests found
......@@ -41,8 +41,15 @@ namespace PseudoRandomGenerator
/// <returns>A pseudo-random integer between min and max</returns>
public int Next(int min, int max)
{
long nextValue = Next();
//Checks if the number is negative
if(nextValue < 0)
{
// Adds modulo to prevent negative random numbers
nextValue += m;
}
// Map the result of Next() to the specified range
return (int)(Next() % (max - min)) + min;
return (int)(nextValue % (max - min)) + min;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment