Skip to content

Commit

Permalink
Negative random should not return absurd values
Browse files Browse the repository at this point in the history
  • Loading branch information
cotillion committed Dec 31, 2014
1 parent 2459e54 commit 3fa56ba
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion random.c
Expand Up @@ -77,7 +77,7 @@ clear_random_seed() {
long long
random_number(long long n)
{
if (!n)
if (n <= 0)
return 0;
return ((unsigned long long)JKISS() * 4294967296 + (unsigned long long)JKISS()) % n;
}
Expand Down

0 comments on commit 3fa56ba

Please sign in to comment.