Fixed division by zero in RNG

Random number generator now returns zero for range [0, 0)
This commit is contained in:
alexey.lysiuk 2016-01-04 12:15:14 +02:00
parent f1cd22ef34
commit 02ff3291bd

View file

@ -57,7 +57,9 @@ public:
// Returns a random number in the range [0,mod) // Returns a random number in the range [0,mod)
int operator() (int mod) int operator() (int mod)
{ {
return GenRand32() % mod; return (0 == mod)
? 0
: (GenRand32() % mod);
} }
// Returns rand# - rand# // Returns rand# - rand#