1
0
Fork 0

fixed seeding of rng

This commit is contained in:
Jan Steemann 2012-09-25 09:27:43 +02:00
parent 27dc95dd35
commit aeb9f5126b
1 changed files with 4 additions and 7 deletions

View File

@ -376,15 +376,12 @@ namespace triagens {
// MERSENNE
struct UniformIntegerMersenne : public UniformIntegerImpl {
int32_t random (int32_t left, int32_t right) {
RandMT randomGenerator((uint32_t) time(NULL));
RandMT randomGenerator((uint32_t) RandomHelper::RandomDevice::getSeed());
int32_t result = ((int32_t) randomGenerator.randomMT()) + left;
if (result > right) {
result %= right;
result += left;
}
const int32_t range = right - left + 1;
int32_t result = ((int32_t) randomGenerator.randomMT());
result = (int32_t) abs(result % range) + left;
return result;
}
};